PDA

View Full Version : share کردن فولدر



AmirAlimadadi
چهارشنبه 19 فروردین 1388, 12:45 عصر
با سلام
چه طور می شه یه فولدر رو توی شبکه share کرد. این فولدر رو توی کامپیوترهای دیگه هم می خوام درست کنم و share کنم.
من یه برنامه توی اینترنت پیدا کردم که کدش به شکل زیر هست، اما خیل وقتها درست کار نمی کنه!!!
try
{
// Create a ManagementClass object
ManagementClass managementClass = new ManagementClass("Win32_Share");
// Create ManagementBaseObjects for in and out parameters
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
// Set the input parameters
inParams["Description"] = Description;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0; // Disk Drive
//inParams["MaximumAllowed"] = int maxConnectionsNum;
// Invoke the method on the ManagementClass object
outParams = managementClass.InvokeMethod("Create", inParams, null);
// Check to see if the method invocation was successful
if ((uint) (outParams.Properties["ReturnValue"].Value) != 0)
{
throw new Exception("Unable to share directory.");
}
}
catch (Exception ex)
{
MessageBox.Show(ex.Message, "error!");
}
}

AmirAlimadadi
شنبه 22 فروردین 1388, 10:23 صبح
سلام به همه، کسی نمی دونه.
یه بار دیگه سوال رو تکرار می کنم.
من توی شبکه می خوام توی کامپیوترهای دیگه یه فولدر درست کنم و اون رو Share کنم.
چه طور می تونم این کار رو بکنم