问题
I'd rather not have to resort to calling the command line.
I'm looking for code that can map/disconnect a drive, while also having exception handling.
Any ideas?
回答1:
Use P/Invoke and WNetAddConnection2
There should also be some wrappers out there to do some of the grunt work for you.
Google is your friend, as always.
回答2:
Here is an article for using a class for interfacing to the "map network drive" windows interface: C# Map Network Drive (API)
来源:https://stackoverflow.com/questions/8919/looking-for-best-practice-for-doing-a-net-use-in-c-sharp