Click here to Skip to main content
15,894,405 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
How I upload a file url to my folder which is in remote server
Posted
Comments
Krunal Rohit 3-Apr-14 0:50am    
File URL ??

-KR
Er. Puneet Goel 3-Apr-14 0:53am    
you want upload file or url??? Please post proper details
mepiya 3-Apr-14 0:56am    
url
Charan_Kumar 3-Apr-14 1:49am    
ask question properly?
What will you do with that URL? Please think what you have asked.

1 solution

C#
File.copy(src, dest);

//use this to copy file from one point to another

// if u would like copy onto another server then use ftp



C#
public void ftpfile(string ftpfilepath, string inputfilepath)  
{  
    string ftphost = "127.0.0.1";  
    //here correct hostname or IP of the ftp server to be given  

    string ftpfullpath = "ftp://" + ftphost + ftpfilepath;  
    FtpWebRequest ftp = (FtpWebRequest)FtpWebRequest.Create(ftpfullpath);  
    ftp.Credentials = new NetworkCredential("userid", "password");  
    //userid and password for the ftp server to given  

    ftp.KeepAlive = true;  
    ftp.UseBinary = true;  
    ftp.Method = WebRequestMethods.Ftp.UploadFile;  
    FileStream fs = File.OpenRead(inputfilepath);  
    byte[] buffer = new byte[fs.Length];  
    fs.Read(buffer, 0, buffer.Length);  
    fs.Close();  
    Stream ftpstream = ftp.GetRequestStream();  
    ftpstream.Write(buffer, 0, buffer.Length);  
    ftpstream.Close();  
}
 
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