问题
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