Click here to Skip to main content
15,032,024 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
Looking for some help with the following.
Need to get a file list of all files in a folder.
Use part of the file name to look for an entry in a MySQL tablet.

What I have tried:

The below code will get me the file names but I am not sure how to store this in memory and then look at the table to find a match.
C#
// Get a list of all subdirectories
         var files = from file in
         Directory.EnumerateFiles(root)
                     select file;
         Console.WriteLine("Files: {0}", files.Count<string>().ToString());
         Console.WriteLine("List of Files");
         foreach (var file in files)
         {
             Console.WriteLine("{0}", file);
         }
Posted
Updated 7-Jul-21 21:27pm
v2
Comments
Richard MacCutchan 7-Jul-21 12:34pm
   
The LINQ code returns a list of the files as you requested. So what part of the MySQL code are you having problems with?
MIDCOPC 7-Jul-21 17:14pm
   
I don't know where to start. I have the file list going to the console but I need save it in memory then search the table to see if any file names match records in the table.
Richard MacCutchan 8-Jul-21 4:02am
   
Look at PIEBALDconsult's suggestion below.
PIEBALDconsult 7-Jul-21 13:09pm
   
If you need the list in memory (which you don't), then don't use EnumerateFiles; use GetFiles.

1 solution

   
Comments
MIDCOPC 8-Jul-21 19:53pm
   
Thank you. After reading this I was able to get what I needed.
Maciej Los 9-Jul-21 2:07am
   
Great!

Cheers!
Maciej

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