string path = Server.MapPath("js/123.js"); if(File.Exists(path)) { File.Delete(path); } StreamWriter sw = File.CreateText(path); Random rd = new Random(); sw.WriteLine(rd.Next().ToString().Trim()); sw.Close();
void AddFullControl(string filename) { FileSecurity fs = File.GetAccessControl(filename); fs.AddAccessRule(new FileSystemAccessRule("Everyone", FileSystemRights.FullControl, AccessControlType.Allow)); File.SetAccessControl(filename, fs); }