Visual C# Developer Center > Visual C# Forums > Visual C# General > How do i make DirectoryInfo from ftpdirectory?
Ask a questionAsk a question
 

AnswerHow do i make DirectoryInfo from ftpdirectory?

  • Friday, November 06, 2009 2:41 PMRafael Vasques Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Has Code
    Im doing some method to check FileVersionInfo.Build,Private,Major and MinorPart from each file inside my FTP.

    in brute, im triing to do:
    DirectoryInfo dir = new DirectoryInfo(FtpAdress);
                        FileInfo[] fileInfos = dir.GetFiles();
    

Answers

  • Saturday, November 07, 2009 12:59 PMTotalllama Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The FTP Protocol does not have the capabilities to serve the information you require.  At best it will allow you to see Name, Size, Attributes/Permissions.  You would need to download the file to the local filesystem then use FileVersionInfo from there.

    In .NET 2.0 you can use the HttpWebRequest methods to make downloading possible then use the FileVersionInfo class to extract the information you require.  If you are targetting the .NET1.x framework then you need to do some sockets programming to allow you to download via FTP.

All Replies

  • Friday, November 06, 2009 2:58 PMGanesh Ranganathan - Bangalore, India Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    You need to use the WinINet WIN32 API to do that. There are a lot of open source clients avaliable which can do the job for you.

    One of them is http://www.codeproject.com/KB/IP/ftplibrary.aspx
    Ganesh Ranganathan
    [Please mark the post as answer if it answers your question]
    blog.ganeshzone.net
  • Friday, November 06, 2009 3:03 PMRafael Vasques Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     
    i will make more clearily my question,

    how i check FileVersionInfo. from some file inside my ftp.
    i dont saw nophing can helpme on this site u showed.
  • Saturday, November 07, 2009 12:59 PMTotalllama Users MedalsUsers MedalsUsers MedalsUsers MedalsUsers Medals
     Answer
    The FTP Protocol does not have the capabilities to serve the information you require.  At best it will allow you to see Name, Size, Attributes/Permissions.  You would need to download the file to the local filesystem then use FileVersionInfo from there.

    In .NET 2.0 you can use the HttpWebRequest methods to make downloading possible then use the FileVersionInfo class to extract the information you require.  If you are targetting the .NET1.x framework then you need to do some sockets programming to allow you to download via FTP.