Click to See Complete Forum and Search --> : directory attributes
wheels619
July 13th, 2006, 01:33 PM
I noticed that the FileAttributes has the normal properties of a directory/file like if it's readOnly, hidden, etc. but I don't see an attribute to determine if the directory/file is sharable. Would I have to access the file's ACL to determine if a file is sharable?
mcmcom
July 13th, 2006, 02:30 PM
sharing is not a naitive property of the FileAttributes class therefore it cannot be accessed that way. shares in windows are determined by the registry and you will have to look there to get a listing of shared dirs. I dont think you can specifty a folder and see if its shared. Try searching for C# + UNC SHARES.
hth,
mcm
darwen
July 13th, 2006, 06:39 PM
Accessing share information directly through the registry isn't an advisable idea. It's better to use WMI.
Have a look here. (http://msdn.microsoft.com/library/default.asp?url=/library/en-us/wmisdk/wmi/win32_share.asp)
It's a start point : not the solution.
You'll need to look up the Windows Management Infrastructure classes and reference here (http://msdn.microsoft.com/library/?url=/library/en-us/cpguide/html/cpconmanagingapplicationsusingwmi.asp?frame=true).
Darwen.
wheels619
July 18th, 2006, 05:48 PM
great; thanks for the link; i came up with this; this will display the shared folders under its shared name;
static void runWMICommand()
{
string qs = "select * from Win32_Share";
ObjectQuery q = new ObjectQuery(qs);
ManagementObjectSearcher sr = new ManagementObjectSearcher(q);
foreach (ManagementObject obj in sr.Get())
{
Console.WriteLine(obj["Name"]);
}
}
codeguru.com
Copyright Internet.com Inc., All Rights Reserved.