0

I need create smb share using c# in local machine. Is possible? Need I use powershell? I am using Visual Studio 2019. I don't found any documentation about this

1
  • You can create a "share" in PowerShell ... or in C# ... or manually, in Windows file Explorer ... or many other ways. Q: Must you create the share programmatically (e.g. in a C# program), or can you use Windows Explorer? Q: Any constraints/restrictions (e.g. must the share be compatible with Ubuntu Samba)? For example: askubuntu.com/questions/1009455/…
    – paulsm4
    Commented Aug 13, 2020 at 19:34

1 Answer 1

1

I need create smb share using c# in local machine. Is possible?

Given that other programs do it, and C# is capable at the end as last resort to call the native API, it is obviously possible.

Need I use powershell?

No.

I am using Visual Studio 2019.

As irrelevant as it gets - VS is an IDE, which is a VERY glorified editor. It does not write code for you.

You have basically multipel avenues:

Sample code, which I found in 30 seconds using google (but you ahve to know "WMI" as keyword) is in example at https://www.codeproject.com/Articles/18624/How-to-Share-Windows-Folders-Using-C

Using WMI you can use

ManagementClass managementClass = new ManagementClass("Win32_Share");

THere is a whole code sample there, but I am not going to steal it.

Not the answer you're looking for? Browse other questions tagged or ask your own question.