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 can Follow It
Try using the net use command in your script to map the share first, because you can provide it credentials. Then, your copy command should use those credentials.
It could be on a hard drive on this computer, or on a network. Check to make sure that the disk is properly inserted, or that you are connected to the Internet or your network, and then try again. If it still cannot be located, the information might have been moved to a different location.
Once the ssh client software is installed you can use the scp command to connect and transfer files to/from the remote machine (the Raspberry Pi running the ssh server). The basic form of the command is scp , the source file name, then the destination file name.
You could use the little impersonation class I wrote some years ago:
using ( new Impersonator( "myUsername", "myDomainname", "myPassword" ) )
{
// code that executes under the new context.
File.Copy( x, y );
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With