Reputation: 1031
First I'll describe my environment: My comupter called AAA is connected to a computer named BBB. I want that my c# application, which runs from AAA will map the CD and DVD drives on BBB and than will copy the CD and DVD drives on BBB to a location in BBB hard disk.
that means that I want to execute a copy operation in BBB computer from remote by c# code. I have the local administrator password of BBB.
any code suggestion? if you can attach code sample it will be helpful.
note: I'm using windows.
Thanks.
Upvotes: 0
Views: 1624
Reputation: 131706
If the CD drive is shared you can copy files just as you would do with local files, using the \\computer\share\somefile path. Eg.
File.Copy(@"\\BBB\MyDrive\MyFile",@"C:\MyFile")
will copy a file from the remote drive to the local disk
If the remote drive isn't shared you can still access it if you know its drive letter using the form \computer\drive$, eg. \\BBB\d$ . File.Copy will work as before only if your account has administrator privileges on the remote computer.
If your account doesn't have the necessary privileges, you will have to provide them using impersonation as File.Copy doesn't accept credentials. Check How to provide user name and password when connecting to a network share for a simple way to pass the credentials.
Upvotes: 0
Reputation: 9952
Probably you would have to map the CD/ DVD drive of BBB in computer AAA and give Read/ Write access permission to computer AAA user which would run your application.
Happy coding!!
Upvotes: 0