This question already has an answer here:
I am writing console application which will Copy file from my local disk to file server. This folder is protecting by username and password. File.Copy()
method does not work. It gives permission error. I have looked to this code
I have tried it but it does not work. First it was written in VB but I have changed the code to C# but there are have some errors. I don't know what does this error mean. Maybe you can advise me other way coping file to protected File Server
with simple File.Copy(bla bla) it gives me "you have not permission"
when i converted VB code to C# it gived me error below: Attempted to read or write protected memory
I have found solution
You could use the little impersonation class I wrote some years ago: