Click here to Skip to main content
15,887,596 members
Home / Discussions / C#
   

C#

 
GeneralRe: Email Delivery Receipt Pin
OriginalGriff1-Dec-14 21:34
mveOriginalGriff1-Dec-14 21:34 
Questionstrong encryption Pin
Jassim Rahma1-Dec-14 0:44
Jassim Rahma1-Dec-14 0:44 
SuggestionRe: strong encryption Pin
Richard MacCutchan1-Dec-14 1:19
mveRichard MacCutchan1-Dec-14 1:19 
Question[Solved] DataGridView, BindingList and combining object properties? Pin
ixilom30-Nov-14 5:54
ixilom30-Nov-14 5:54 
QuestionLink-grammar 5.1.3 /Windows, MSVC Pin
Member 1127414829-Nov-14 18:07
Member 1127414829-Nov-14 18:07 
AnswerRe: Link-grammar 5.1.3 /Windows, MSVC Pin
Garth J Lancaster29-Nov-14 19:06
professionalGarth J Lancaster29-Nov-14 19:06 
QuestionHow to Handle Redirects to Login When Trying to Read Results From HttpWebRequest? Pin
Member 1127231728-Nov-14 15:29
Member 1127231728-Nov-14 15:29 
Questionsetting file's security to 'no delete' in code ? Pin
BillWoodruff28-Nov-14 8:39
professionalBillWoodruff28-Nov-14 8:39 
WinForms Visual Studio 2013/4 .NET 4.5

I'm executing the code shown here without error, and with valid user-domain and filepath values:
C#
using System.IO;
using System.Security.AccessControl;

// in Form scope
private string filePath = validFilepath;

private void setNoDelete()
{
    // current user account
    string user = Environment.UserDomainName + "\\" + validAccountName;
    
    // current security object
    FileSecurity security = File.GetAccessControl(filePath);
    
    // add rule
    security.AddAccessRule(new FileSystemAccessRule(user, FileSystemRights.Delete, AccessControlType.Deny));
    
    // set access
    File.SetAccessControl(filePath, security);
}
But, the test file ... in a folder on the Desktop ... can still be deleted in the usual way after this is called.

One hypothesis is that my current user-account has some kind of elevated privileges that cannot be over-ridden by executing this code, but I am not at the place I can really evaluate that idea.

Appreciate any response !
«If you search in Google for 'no-one ever got fired for buying IBM:' the top-hit is the Wikipedia article on 'Fear, uncertainty and doubt'»  What does that tell you about sanity in these times?


modified 2-Dec-14 3:04am.

QuestionRe: setting file's security to 'no delete' in code ? Pin
Eddy Vluggen28-Nov-14 8:54
professionalEddy Vluggen28-Nov-14 8:54 
AnswerRe: setting file's security to 'no delete' in code ? Pin
BillWoodruff28-Nov-14 14:11
professionalBillWoodruff28-Nov-14 14:11 
GeneralRe: setting file's security to 'no delete' in code ? Pin
Eddy Vluggen1-Dec-14 8:02
professionalEddy Vluggen1-Dec-14 8:02 
GeneralRe: setting file's security to 'no delete' in code ? Pin
Manfred Rudolf Bihy1-Dec-14 9:01
professionalManfred Rudolf Bihy1-Dec-14 9:01 
AnswerRe: setting file's security to 'no delete' in code ? Pin
Dave Kreskowiak28-Nov-14 10:24
mveDave Kreskowiak28-Nov-14 10:24 
GeneralRe: setting file's security to 'no delete' in code ? Pin
BillWoodruff28-Nov-14 14:12
professionalBillWoodruff28-Nov-14 14:12 
AnswerRe: [still unsolved as of Dec. 1] setting file's security to 'no delete' in code ? Pin
Manfred Rudolf Bihy1-Dec-14 2:02
professionalManfred Rudolf Bihy1-Dec-14 2:02 
AnswerRe: [still unsolved as of Dec. 1] setting file's security to 'no delete' in code ? Pin
Manfred Rudolf Bihy1-Dec-14 3:01
professionalManfred Rudolf Bihy1-Dec-14 3:01 
GeneralRe: [still unsolved as of Dec. 1] setting file's security to 'no delete' in code ? Pin
BillWoodruff1-Dec-14 21:12
professionalBillWoodruff1-Dec-14 21:12 
GeneralRe: [still unsolved as of Dec. 1] setting file's security to 'no delete' in code ? Pin
Manfred Rudolf Bihy2-Dec-14 18:44
professionalManfred Rudolf Bihy2-Dec-14 18:44 
GeneralRe: [still unsolved as of Dec. 1] setting file's security to 'no delete' in code ? Pin
Manfred Rudolf Bihy3-Dec-14 21:17
professionalManfred Rudolf Bihy3-Dec-14 21:17 
QuestionWrite to Registry with Administrative Privileges Pin
Jassim Rahma28-Nov-14 1:36
Jassim Rahma28-Nov-14 1:36 
AnswerRe: Write to Registry with Administrative Privileges Pin
Richard MacCutchan28-Nov-14 2:50
mveRichard MacCutchan28-Nov-14 2:50 
AnswerRe: Write to Registry with Administrative Privileges Pin
Pete O'Hanlon28-Nov-14 3:17
mvePete O'Hanlon28-Nov-14 3:17 
GeneralRe: Write to Registry with Administrative Privileges Pin
Jassim Rahma28-Nov-14 9:21
Jassim Rahma28-Nov-14 9:21 
GeneralRe: Write to Registry with Administrative Privileges Pin
Richard MacCutchan28-Nov-14 22:34
mveRichard MacCutchan28-Nov-14 22:34 
GeneralRe: Write to Registry with Administrative Privileges Pin
Jassim Rahma29-Nov-14 4:57
Jassim Rahma29-Nov-14 4:57 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.