Getting a file list from an HTTP server

I need to download a list of images from a web server using VB and webclient. I know the name of the folder but will not know the names of the files in the folder. They will be jpg images with the name following a general formate of img_####.jpg. What I would like to get is a list of names that I can use in a scroll box. Is this possible How can it be done

Thanks,

Neal




Answer this question

Getting a file list from an HTTP server

  • weary

    Hi Neal,

    You can do this with WebClient but you'll have to parse the output yourself.

    You can do something like:

    WebClient client = new WebClient();

    Byte[] pageData = client.DownloadData("http://yourservername/yourscriptsdirectory/");

    string pageHtml = Encoding.ASCII.GetString(pageData);

    Now you'll have to parse pageHtml for the names of the image files in the format you want.

    In case you have an ftp server you can use FtpWebRequest class with the method set to "NLST" (WebRequestMethods.Ftp.ListDirectory)

    Let me know if this helped

    Mariya


  • Getting a file list from an HTTP server