0
Q
共享文件夾槽C#
A
回答
1
此代碼共享文件夾這裏
private static void QshareFolder(string FolderPath, string ShareName, string Description)
{
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
//Another Type:
// DISK_DRIVE = 0x0
// PRINT_QUEUE = 0x1
// DEVICE = 0x2
// IPC = 0x3
// DISK_DRIVE_ADMIN = 0x80000000
// PRINT_QUEUE_ADMIN = 0x80000001
// DEVICE_ADMIN = 0x80000002
// IPC_ADMIN = 0x8000003
//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!");
}
}
更多細節http://www.codeproject.com/Articles/18624/How-to-Share-Windows-Folders-Using-C
+0
非常好。謝謝。 – Raskolnikov
+0
不客氣 – Mostafiz
相關問題
- 1. 共享的源文件夾,如C#
- 2. C#.Net 4檢索共享文件夾
- 3. C#Dropbox Api檢索公共共享文件夾的文件
- 4. centos5 git共享文件夾
- 5. DropBox文件夾共享
- 6. EPiServer共享文件夾VPP
- 7. 共享文件夾API
- 8. 上的共享文件夾
- 9. Windows文件夾共享API
- 10. SourceSafe共享文件夾?
- 11. 從firebase共享文件夾
- 12. 共享文件夾在owncloud
- 13. 共享文件夾和XCode
- 14. EC2共享WWW文件夾
- 15. Outlook NewMailEx共享文件夾
- 16. Dropbox API - 共享文件夾
- 17. 共享子文件夾ownCloud
- 18. 共享文件夾權限!
- 19. 共享文件夾執行
- 20. 如何在Linux中通過PHP共享或複製共享文件夾中的共享文件夾
- 21. 如何通過C#從共享文件夾讀取文件?
- 22. PowerShell共享文件夾上的共享權限級別
- 23. 添加共享文件夾使用共享鏈接
- 24. 如何從C#中的EWS(ExchangeService)訪問組文件夾/共享文件夾
- 25. 將本地文件夾中的郵件複製到公共/共享文件夾
- 26. 如何獲得公共共享文件/文件夾的鏈接
- 27. Windows搜索共享文件夾
- 28. 項目文件夾中的共享庫
- 29. Box.com共享鏈接文件夾
- 30. Filestream共享文件夾權限問題
您需要添加參考'System.Management' DLL和相應的代碼。 – Bikee
你有沒有檢查過https://msdn.microsoft.com/en-us/library/bb425864.aspx文章並嘗試設置'WHSSharePermissions'枚舉?或者也許有一種方法可以在WMI中做到這一點.. –
總體而言,我們不會爲你編碼這樣的東西 - 在你的許多googlings中你沒有找到任何代碼嘗試? – BugFinder