Click here to Skip to main content
15,886,578 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Hi
I would like to know how could I scan multiple directories on a server to find a file that contains the value of a string that i define.

Basically what i need to achieve is i have a server with multiple directories which contain text files of products, the text files naming convention contains the product id,i created an array of the products that i need to find and when looping through the array i want to find the product file path of the current array value so that i can reference the file path in an XML file that gets exported to an external system.

Thanks
Posted
Comments
Sergey Alexandrovich Kryukov 2-Feb-16 9:43am    
Don't you think you should better use a database?
As to scanning files, what's the problem? What have you tried so far?
—SA
NightWizzard 2-Feb-16 13:34pm    
You can do a reverse loop through all directories and their files using the file system objects and read the content of each file into a string variable in one step (read all bytes). Then use the IndexOf method to check for the searched string.

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