开发者

Copy a file on a network path without transfering it to my own machine

开发者 https://www.devze.com 2023-01-16 12:11 出处:网络
If my .NET client uses System.IO.File.Copy to copy a file from \\server1\\share1\\file1.txt to \\sever1\\share2\\file2.txt, the file\'s data get read down to the client and then written back up to the

If my .NET client uses System.IO.File.Copy to copy a file from \server1\share1\file1.txt to \sever1\share2\file2.txt, the file's data get read down to the client and then written back up to the server.

Is there an easy way to speed up things a bit by putting a process on the network-machine that realy does the copying?

I dont look for adv开发者_开发知识库ice on programming such a service. I would rather find the tool or windows-functionality that already does this.


This sounds like a job for telnet or ssh, but these can be a pain to set up. I recommend you look at PsExec from microsoft which allows you to execute programs on a remote machine. You could simply use the copy program found in system32 through PsExec.

There is no need to create your own program to do this, just use the command line tools found on the target machine.


Almost certainly. I can think of a couple basic ways to do it:

  1. Create a simple console applicaton that takes the source and destination paths/filenames, and performs a File.Copy(). Place it on the remote machine in a known location. Then invoke the process on the remote machine using PsExec. Your client app must be running in full trust in order to invoke a process programmatically, and the user running the app must have permission to run programs on the remote server.

  2. Create a simple web method that again takes the source and destination and performs the copy. This requires setting up IIS on the network server with the requisite permissions to perform file access outside of the IIS "sandbox". However, it requires fewer client code permissions.


FYI CopyFileEx already does this if your client and server are Vista and later. So, not point in duplicating any of that effort in that case.

-scott

0

精彩评论

暂无评论...
验证码 换一张
取 消