Create Network Share with permissions

无人久伴 提交于 2019-12-23 04:26:11

问题


I didn't find any good info or library on the inet, about how to create a network share and set permission for a local group. I'm using c# and Windows Server 2008.

Does anyone have some good resources or sample to point me in the right direction?


回答1:


You can use Pinvoke or WMI,

there is a very nice article on this on Code Project: How to create a file share using .NET framework

the key of the whole thing is the following Windows API:

[DllImport("Netapi32.dll")]
public static extern int NetShareAdd([MarshalAs(UnmanagedType.LPWStr)]
string strServer, Int32 dwLevel, IntPtr buf, IntPtr parm_err);

for using WMI, MSDN "knows": Create method of the Win32_Share Class



来源:https://stackoverflow.com/questions/7470214/create-network-share-with-permissions

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!