static void Main(string[] args) { //Win32Share w = new Win32Share(); var name = (from x in new ManagementObjectSearcher("SELECT * FROM Win32_OperatingSystem").Get().OfType <ManagementObject>() select x.GetPropertyValue("Caption")).FirstOrDefault(); Console.WriteLine(name != null ? name.ToString() : "Unknown"); //Create(args[1], args[0]); SharedDrive drive = new SharedDrive(args[0]); drive.Create(args[1], "This is the share", "Everyone", FileSystemRights.ReadAndExecute, FileSystemRights.Synchronize); //SharedDrive drive1 = new SharedDrive(args[0]); //drive1.SetUserRights("AMERICAS", "youngmak", FileSystemRights.ReadAndExecute, FileSystemRights.Synchronize); //drive1.SetUserRights("AMERICAS", "schroath", FileSystemRights.ReadAndExecute, FileSystemRights.Synchronize); //var y = Environment.OSVersion; //if ((y.Version.Major == 6 && y.Version.Minor < 2) || y.Version.Minor < 6) //{ //} //else if (y.Version.Minor) //Win32Share.Foo(); }
/// <summary> /// Gets all shares. /// </summary> /// <returns>IList<SharedDrive>.</returns> public static IList <SharedDrive> GetAllShares() { IList <SharedDrive> result = new List <SharedDrive>(); ManagementClass management = new ManagementClass("Win32_Share"); ManagementObjectCollection managementItems = management.GetInstances(); foreach (ManagementObject item in managementItems) { SharedDrive share = new SharedDrive(item); result.Add(share); } return(result); }