C
C#17mo ago
Silentgamerz

✅ 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
sibber17mo ago
of course
DKMK100
DKMK10017mo 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
RubyNovaDev17mo ago
yeah that's totally doable
Doombox
Doombox17mo ago
you can also use known headers if you can't rely on the extensions for whatever reason
Florian Voß
Florian Voß17mo ago
Directory.EnumerateFiles() will come in handy
DKMK100
DKMK10017mo ago
"known" being the technicality that gets you But yea practically this is easy
Denis
Denis17mo ago
But name are you referring to the filename, or the file properties?
Denis
Denis17mo ago
Denis
Denis17mo ago
These are the file properties (metadata)
Denis
Denis17mo ago
this is the filename + extension (jpg)
Silentgamerz
SilentgamerzOP17mo 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
Denis17mo 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
SilentgamerzOP17mo 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
Denis17mo 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
Accord17mo 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.
Want results from more Discord servers?
Add your server