1
Reply

FTP Remote path and get file properties in C#

    Any one please guide me to get remote file properties from ftp server,i can access the directory and files name via "ftp://servername/directoryname" through web request class and through ftp.list directory method.but to get the file size if i send the same path it says invalid path.

     

    FtpWebRequest ftp;

     ftp = (FtpWebRequest)FtpWebRequest.Create(new    Uri("ftp://"+ftpServerIP+"/Directory name"));

     ftp.Credentials = new NetworkCredential(ftpUserID, ftpPassword);

     ftp.Method = WebRequestMethods.Ftp.GetFileSize;           

    WebResponse response = ftp.GetResponse();

    long filesize = response.ContentLength;

     

              The code can be in vb.net or c#.net.please help me