hello guys trying make functionality in application user should not able delete file within folders , icons on desktop...till able user can't open folder when giving filesystemrights delete not working...how can achieve please me ....
here code..
public string p = @"d:\\test"; public string sysloguser = system.security.principal.windowsidentity.getcurrent().name; public void freezefile(string path, string user) { system.io.directoryinfo folderinfo = new system.io.directoryinfo(path); directorysecurity foldersecurity = folderinfo.getaccesscontrol(); filesystemaccessrule rule = new filesystemaccessrule(user, filesystemrights.readdata, inheritanceflags.objectinherit, propagationflags.none, accesscontroltype.deny); foldersecurity.addaccessrule(rule); directory.setaccesscontrol(path, foldersecurity); } private void btn_action_click(object sender, eventargs e) { this.freezefile(p,sysloguser); messagebox.show("permissions altered successfully"); }
Comments
Post a Comment