Create Network Share with permissions

2019-06-09 21:09发布

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条回答
小情绪 Triste *
2楼-- · 2019-06-09 21:29

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

查看更多
登录 后发表回答