Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Access a shared folder(which is protected)

I need help in writing a C# script which can access a secured shared location(i hv the username and password) in order to access some files from that location and also dump some files over there pragmatically. Thank you in advance

like image 899
S.. Avatar asked Jul 11 '26 21:07

S..


1 Answers

To access a network share that is protected you need to call LogonUser and do impersonation within your application. The MSDN article provides a code sample. Then you can just browse, copy/move, etc with the System.IO namespace. For instance:

System.IO.Directory.GetFolders(@"\\Server\Share");

will return a list of the folders on the network share.

like image 93
Adam Gritt Avatar answered Jul 14 '26 10:07

Adam Gritt



Donate For Us

If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!