How do I make a duplicate of a folder on a remote server with asp.net and keep it speedy?
I have an ASP.NET page that needs to make a duplicate of a folder that resides on another server. All of the file IO runs on the remote server. This is not a question about how to copy files from 开发者_StackOverflow社区one computer to another, nor is it a question about how to do a recursive directory copy. Those tasks are pretty easy.
What I've found is that making a copy of a directory on the server running the ASP.NET application is nice and fast. As soon as the source and destination folder reside on a remote server (i.e. a file server), it becomes incredibly slow. I can't figure out why it's so slow, which means I can't really figure out a good way to get around the problem. To be perfectly clear, here's an example of what I'm trying to accomplish:
- The asp.net application is running on a server named "webserver"
- The files are located on a server named "fileserver"
- I need the website running on "webserver" to make a recursive duplicate of \\fileserver\files\setup named \\fileserver\files\setup_temp
If there are already answers to this question then please point me in the right direction. I found loads of answers to the "how do I make a recursive copy" and "how do I copy a folder to another server"
I would recommend using some remote execution commands instead of doing that from the web app itself. For e.g., using Powershell or PSExec that will not require your web app to keep a connection for the two end points of the copy operation. I am not sure how you are doing the copy but if you are calling anything in .NET to do that work, that means your server is a middle man for that operation and that will slow it down.
When I re-read your message, it looks like you are thinking the IO happens on the remote server itself. In which case, these suggestions might not be of much use. :(
How does the Webserver communicate with the Fileserver? The transfer of data between those two is definitely your bottleneck. I would recommend using a WCF service to transfer one file/folder at a time (depending on the size of the data). If the files are really large i would also recommend enabling streaming.
精彩评论