✅ is there a way to read names of image files

I want to create a program tht reads name of image all files in a folder and uploads it to a SQL database
15 Replies
sibber
sibber2y ago
of course
DKMK100
DKMK1002y ago
Probably The only thing that might give you trouble is knowing for sure it's an image file since there might be some weird image file extensions and formats out there But yea getting a list of all pngs and jpegs and stuff in a folder should be super easy
RubyNovaDev
RubyNovaDev2y ago
yeah that's totally doable
Doombox
Doombox2y ago
you can also use known headers if you can't rely on the extensions for whatever reason
Florian Voß
Florian Voß2y ago
Directory.EnumerateFiles() will come in handy
DKMK100
DKMK1002y ago
"known" being the technicality that gets you But yea practically this is easy
Denis
Denis2y ago
But name are you referring to the filename, or the file properties?
Denis
Denis2y ago
Denis
Denis2y ago
These are the file properties (metadata)
Denis
Denis2y ago
this is the filename + extension (jpg)
Silentgamerz
SilentgamerzOP2y ago
There would be a specific folder only where users will upload only a specific type of image (png) Filename - ProfilePicture Can you send me any doc links or tell which code or functions can be used to solve this issue
Denis
Denis2y ago
Then this is a pretty trivial problem to solve. You'll have to use Path.GetFilenameWithoutExtension(pathToFile) to get the filename And if you wish to process a new image once it is added to said folder, you'll need to use a FileSystemWatcher It will provide you events for catching any new images in the folder For processing existing images in the folder you'll have to use Directory.EnumerateFiles. That'll get you file paths within a given directory, you can process those paths as you desire.
Silentgamerz
SilentgamerzOP2y ago
Thank you 😁 Oh also are I don't understand the tags Am I supposed to use begginer tag to tell whether I am a beginner or the difficulty level of the problem
Denis
Denis2y ago
I tag that you are a beginner. Because with the basic experience you might not be able to correctly asses the difficulty of the task but feel free to ask the mods what is the intention behind the tags
Accord
Accord2y ago
Was this issue resolved? If so, run /close - otherwise I will mark this as stale and this post will be archived until there is new activity.

Did you find this page helpful?