简体   繁体   中英

Copy operation from remote machine

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.

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!!

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.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM