✅ 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
of course
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
yeah that's totally doable
you can also use known headers if you can't rely on the extensions for whatever reason
Directory.EnumerateFiles()
will come in handy"known" being the technicality that gets you
But yea practically this is easy
But
name
are you referring to the filename, or the file properties?These are the file properties (metadata)
this is the filename + extension (jpg)
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
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.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
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
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.