Click here to Skip to main content
15,885,366 members
Please Sign up or sign in to vote.
1.57/5 (3 votes)
Hii Dear Friends


how are you all...
I have a problem with file copying in asp .net web application.I would like to copy files from a folder in one web application to another. Could you please tell me how to do this?


Thank You all... :)
Posted
Updated 26-Aug-17 20:32pm
Comments
Praveen Kumar Upadhyay 1-Dec-14 8:46am    
Using FTP would be the safest and fine way.
Herman<T>.Instance 4-Feb-15 10:33am    
not necessarily the safest but probably the fastest
Frank Kerrigan 4-Mar-16 15:18pm    
Are these servers on the same domain / network or are on different parts of the internet behind firewalls etc...

Using FTP with specific username and password can solve your problem.

If you use WebServices, some times it will be difficult to serialize and de-serialize at both ends and some times you will have constraints with file size.

Better go with FTP, and if you need security use FTPS. Your can use WebClient object to connect with FTP.
 
Share this answer
 
you can use webclient :-

private void SaveFileOnFTPLocation(string sourceFile,string ftpPath)
    {
        WebClient webClient = new WebClient();
        webClient.Credentials = new NetworkCredential(@"user", @"pwd");
        string sFtpToReadFileFrom = ftpPath;
        System.IO.File.copy(sourceFile,sFtpToReadFileFrom);
    }
 
Share this answer
 
I have used websevices for this.
 
Share this answer
 
alternative, probably slower than FTP: use Form Post, upload the byte array to another website.
 
Share this answer
 
Comments
CHill60 23-Dec-15 9:31am    
Fair point so I won't downvote - you do realise this post is over a year old?
If the Applications are in the same server Copy using Physical path. or if it is in different the create a WCF service to Copy the files.
 
Share this answer
 
It depends on hosting environment. If its shared hosting then you can zip on old server and extract on new server using Hosting Provider's web method. If it is dedicated and on same server, you can easily copy paste like windows. If it is dedicated and on another server then you can use ftp from old server to new server.
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900