try{ ManagementPath winSharePath = new ManagementPath("Win32_Share");ManagementScope winShareScope = new ManagementScope(@"\\server01\root\cimv2");ManagementClass winShareClass = new ManagementClass(winShareScope,winSharePath,null);ManagementObject shareObject = winShareClass.CreateInstance();shareObject["Path"] = @"E:\Test";shareObject["Name"] = "TestShare$";shareObject["Type"] = 0;shareObject["Description"] = "Test Share Description";PutOptions shareOptions = new PutOptions();shareOptions.Type = PutType.UpdateOrCreate;shareOptions.Timeout = TimeSpan.MaxValue;shareObject.Put(shareOptions);}catch (Exception err){MessageBox.Show(err.Message);}