Introduction
By using this Method you can Easly Share Folders with in C# Programming.
I'm wrote Advanced Feature in Source Code Like Maximum Connection and ...
Using the code
At the first you have to Add Reference : System.Management
From Visual Studio like This Image:
And Then with this Method You Can Easly Share Any Folder You Want :
private static void QshareFolder(string FolderPath, string ShareName, string Description)
{
try{
ManagementClass managementClass = new ManagementClass("Win32_Share");
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Description"] = Description;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0;
outParams = managementClass.InvokeMethod("Create", inParams, null);
if ((uint) (outParams.Properties["ReturnValue"].Value) != 0)
{
throw new Exception("Unable to share directory.");
}
}catch (Exception ex)
{
}
}
Sample Usage:
QshareFolder("c:\\TestShare","Test Share", "This is a Test Share");
As you see I'm Upload Source code of Sample Program i wrote ,and i hope it's useful to Start!
Points of Interest
I'm using this method in one of my Projects that my Users wants to Share Folder With the others And they don't now How! And i think they will be happy now!
And This Link is an Article About How To Reset Windows Administartor Password:
Reset-Administrator-Pass.asp
History
Version 1.0, By: Qasem Heirani Nobari