Click here to Skip to main content
15,896,557 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
C#
public static void Download(string FTPFullFileName, string DestFullFileName)
  {
      try
      {

          DestFullFileName = DestFullFileName.Replace("/", "\\");
          int indexPart = DestFullFileName.LastIndexOf("\\");

          if (indexPart != -1)
          {
              String DestFolder = DestFullFileName.Substring(0, indexPart + 1);

              if (!System.IO.Directory.Exists(DestFolder))
                  Directory.CreateDirectory(DestFolder);
          }

          FtpWebRequest FTP = (FtpWebRequest)FtpWebRequest.Create(FTPFullFileName);
          FTP.Method = WebRequestMethods.Ftp.DownloadFile;
          FTP.UseBinary = true;

          FTP.Proxy = null;
      }
 }


C#
protected void LinkButton1_Click(object sender, EventArgs e)
    {
        
        Download("D://Error.txt", @"E://Error.txt");

    }


when i click on link button,then call download method,
then now i get an exception this line

FtpWebRequest FTP = (FtpWebRequest)FtpWebRequest.Create(FTPFullFileName);

Invalid Uri exception..what we change..how to get the file from the server system
Posted
Comments
DipsMak 28-Feb-14 7:27am    
To download the file you need to provide the credentials also
Siva Hyderabad 28-Feb-14 7:31am    
k,k..but here how to get file
george4986 28-Feb-14 7:31am    
A Valid ftp path is something like below
'ftp://edn@ednworld.in//edn/ednworld.in/wwwroot/Error.txt'
ie the hosted folder path + ur file name
DipsMak 28-Feb-14 7:39am    
Check on FTP Command prompt using your credentials and check you can access the file you want..sharing is also required. to access over ftp.
Siva Hyderabad 28-Feb-14 7:49am    
Download("ftp://sedfe.uwiswAfiPN14s7xVIWxPIA==//wwwroot/Error.txt", @"E://Error.txt");

here i get InvalidURI

1 solution

you should provide a valid FTP-URL for the request.
 
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