views:

41

answers:

3

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 advice on programming such a service. I would rather find the tool or windows-functionality that already does this.

+3  A: 

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.

Callum Rogers
A: 

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.

KeithS
Why create a console app? What's wrong with windows own copy?
Rune FS
You can grant access to your own console app without requiring remote programmatic access to Windows/System32, you can perform server-side validation of additional business rules of the copy to be performed, you can log changes to the file structure for audit reasons, etc. In the basic case there's nothing "wrong" with windows copy, but these things could be valuable now or later.
KeithS
A: 

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

snoone