Hi.I want to lock my folder with c#? How can I do it?
2 Answers
Know the answer? Post it. Somebody with the same question will find it here.
Mike GoldRank #50 · 30.6K pointsPosted Aug 12, 2010, 3:11 PM EDT
0
Not sure what you mean by lock a folder. Do you want to hide a folder in the file system? Make it read-only? Prevent permission access for a particular group?
0
Mike GoldRank #50 · 30.6K pointsPosted Aug 13, 2010, 6:29 AM EDT
DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\temptest");
directoryInfo.Attributes = directoryInfo.Attributes | FileAttributes.ReadOnly;
Unfortunately this won't really do much, because there is not much meaning to setting a directory to readonly. You more likely want to limit write access to a user or group of users through Active Directory. Below is a link on codeproject that tells you how to do almost anything you can think of to restricting permissions to a directory:
http://www.codeproject.com/KB/system/everythingInAD.aspx
Mike GoldRank #50 · 30.6K pointsPosted Aug 12, 2010, 3:11 PM EDT
Mike GoldRank #50 · 30.6K pointsPosted Aug 13, 2010, 6:29 AM EDT
http://msdn.microsoft.com/en-us/library/system.io.directoryinfo_properties.aspx
DirectoryInfo directoryInfo = new DirectoryInfo(@"c:\temptest");
directoryInfo.Attributes = directoryInfo.Attributes | FileAttributes.ReadOnly;
Unfortunately this won't really do much, because there is not much meaning to setting a directory to readonly. You more likely want to limit write access to a user or group of users through Active Directory. Below is a link on codeproject that tells you how to do almost anything you can think of to restricting permissions to a directory:
http://www.codeproject.com/KB/system/everythingInAD.aspx
1 short reply
Abdullah AKALIN22 pointsPosted Aug 13, 2010, 1:13 AM EDT