Access a network share

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

When I want to access a network share in C#
the link is
"\\\\comp\\share\\a.txt"
But if it require password, what can I do?
Since I don't want to map a drive.
Thank you
 
Use DllImport for the WNetAddConnectionX method to authenticate against
\\comp\ipc$ with a username and password. If you don't specify a local name
for the connection, no drive is mapped - but the credentials are associated
with the computer. Then access the file and then remove the connection with
WNetCancelConnection.


Arild
 
Back
Top