0

I have a website that creates a txt file and saves it with a timestamp to the webserver directory.

I need a client based app to list all files in the directory to download to the client server for processing but cannot find a way to have them listed in a listbox without specifying the full file name

i.e. TB2014-09-08_11h48m25_765.txt is a full name. TB stays constant and the files are always .txt)

1 Answer 1

1

you want the GetFiles method in the Directory class (System.IO namespace). Something along these lines:

Dim files As String() = Directory.GetFiles("c:\YourFolder", "TB*.txt")

For Each filename In files
   Console.WriteLine(filename)
Next 
6
  • it works well for local addresses but not for the URL address:"An unhandled exception of type 'System.ArgumentException' occurred in mscorlib.dll Additional information: URI formats are not supported." Sep 8, 2014 at 11:31
  • You can't access a directory listing over http. You would have to use the physical network path. See: stackoverflow.com/questions/15964983/…
    – Matt Wilko
    Sep 8, 2014 at 11:35
  • is mapPath available to use in VB? Sep 8, 2014 at 12:26
  • Yes but that will only get you the path on the server, which is not necesarilly the same as the path from the client.
    – Matt Wilko
    Sep 8, 2014 at 12:26
  • how do I implement it from a VB winform? Sorry I am still new to this whole process and I'm learning on the go. I know the direct URL path but won't know what the full file names are due to the custom date stamps. and yes the date stamps are very important to maintain (used on first-come-first-serve basis) Sep 8, 2014 at 13:46

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.