Mike Gold
posted
520 posts
since
Apr 07, 2005
from
|
|
Re: How can I lock a folder in c#?
|
|
|
|
|
|
|
|
|
|
|
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?
|
|
|
|
|
|
Abdullah AKALIN
posted
17 posts
since
Jun 02, 2010
from
|
|
Re: How can I lock a folder in c#?
|
|
|
|
|
|
|
|
|
|
|
I mean make it read-only.
|
|
|
|
|
|
Mike Gold
posted
520 posts
since
Apr 07, 2005
from
|
|
Re: How can I lock a folder in c#?
|
|
|
|
|
|
|
|
|
|
You can set the Attributes on a file using DirectoryInfo
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
|
|
|
|
|
|