C#实现文件夹共享出现问题了
publicvoidShareNetFolder(stringFolderPath,stringShareName){try{ManagementClassmanagem...
public void ShareNetFolder(string FolderPath,string ShareName){
try
{ ManagementClass managementClass = new ManagementClass("root\\CIMV2","Win32_Share",null);
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0;
inParams["MaximumAllowed"] = null;
inParams["Description"] = null;
inParams["Password"] = null;
inParams["Access"] = null;
outParams = managementClass.InvokeMethod("Create", inParams, null);
if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
MessageBox.Show("失败");
}
else { MessageBox.Show("共享成功"); ShowSharePath(); }
}
catch
{
MessageBox.Show("失败");
}
}
以上是实现 FolderPath路径文件夹共享,运行成功了,但是我在其他电脑上访问时还是打不开这个文件夹,怎么回事啊,难道是权限问题,可是我已经设置了啊,哪位大神能帮助一下,谢谢 展开
try
{ ManagementClass managementClass = new ManagementClass("root\\CIMV2","Win32_Share",null);
ManagementBaseObject inParams = managementClass.GetMethodParameters("Create");
ManagementBaseObject outParams;
inParams["Name"] = ShareName;
inParams["Path"] = FolderPath;
inParams["Type"] = 0x0;
inParams["MaximumAllowed"] = null;
inParams["Description"] = null;
inParams["Password"] = null;
inParams["Access"] = null;
outParams = managementClass.InvokeMethod("Create", inParams, null);
if ((uint)(outParams.Properties["ReturnValue"].Value) != 0)
{
MessageBox.Show("失败");
}
else { MessageBox.Show("共享成功"); ShowSharePath(); }
}
catch
{
MessageBox.Show("失败");
}
}
以上是实现 FolderPath路径文件夹共享,运行成功了,但是我在其他电脑上访问时还是打不开这个文件夹,怎么回事啊,难道是权限问题,可是我已经设置了啊,哪位大神能帮助一下,谢谢 展开
1个回答
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询