0
我需要能够在共享文件夹在局域网中的计算机上安装程序进行安装。找出是否有足够的磁盘空间,在共享文件夹
首先,我必须知道哪些文件夹在计算机上共享,然后检查是否有足够的磁盘空间用于安装。
这是我的方法。
public static void FindShares()
{
try
{
ConnectionOptions options = new ConnectionOptions();
options.Authentication = AuthenticationLevel.PacketPrivacy;
options.Impersonation = ImpersonationLevel.Impersonate;
string path = "\\\\COMPUTERNAME\\root\\cimv2";
ManagementScope scope = new ManagementScope(path, options);
scope.Connect();
ObjectQuery query = new ObjectQuery("SELECT * FROM Win32_Share");
ManagementObjectSearcher searcher = new ManagementObjectSearcher(scope, query);
ManagementObjectCollection queryCollection = searcher.Get();
foreach (ManagementObject m in queryCollection)
{
// Display shared folder information
Console.WriteLine("Share Name : {0}", m["Name"]);
Console.WriteLine("Share Path : {0}", m["Path"]);
Console.WriteLine("AccessMask: {0}", m["AccessMask"]);
Console.WriteLine("Type: {0}", m["Type"]);
Console.WriteLine("Status : {0}", m["Status"]);
Console.WriteLine();
}
string line;
line = Console.ReadLine();
}
catch (Exception e)
{
MessageBox.Show(e.Message);
}
}
当我运行此我得到这个错误: 访问被拒绝。 (从HRESULT异常:0x80070005(E_ACCESSDENIED))
我想我必须建立我的indeonation不同,但我不知道如何。
谢谢你的帮助。