Click here to Skip to main content
15,566,366 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
So I want my code to read the filenames in a directory, because the files there are constantly changing. Is there an easy way or recommended way of doing this?


What I have tried:

I can only manually specify the string of the filename in code
Updated 8-Oct-21 20:04pm

You can use the FileSystemWatcher[^] to continuously watch the directories of interest. This would provide you with enough information about the directories, and what changes have been made in the file system.
Share this answer
Admin BTA 10-Oct-21 14:57pm    
Awesome. Extremely helpful - thank you!
In addition to what Afzaal has said, you shoudl also look at the Directory class[^]
It contains methods for listing directories: Directory.GetFiles Method (System.IO) | Microsoft Docs[^] among other things.
You should also look at the very useful Path Class[^] which can help a lot with file names and paths.
Share this answer
Admin BTA 10-Oct-21 14:57pm    
Very helpful! Thanks!

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