A quick question.
How do i in the easiest and securest way get all images from a folder in my solution without having to copy them to the debug folder.
So lets say this is my folder structure:
Project
Resources (Folder)
Images (Folder)
HelpIcons (Folder)
Icon1.png
Icon2.png
How do i get the icon1 and icon2 from the code? (without copy to debug)
If it is in a compiled section of code you should be able to just hit the root and then come back up to the directory e.g. /Resources/Images/HelpIcons/
If you are accessing the images from a front end file e.g .aspx try ~/Resources/Images/HelpIcons
You can do some like
Server.MapPath("~/Images/HelpIcons")
or whatever the virtual path is if this is in a web project.Alternatively, you can get the current execution directory and work your way from there
Directory.GetCurrentDirectory()
see http://msdn.microsoft.com/en-us/library/system.io.directory.getcurrentdirectory(v=vs.71).aspx
Once you have the starting point you get children directories with
Directory.GetDirectories(string path)
and the files withDirectory.GetFiles(string path)
You can use GetFiles from the directory you specified.
filenames
contains a list of all filenames in that directory, from here you can then look for ".png"--Edit 12:13--
This will be starting from the directory where your executable is. You can specify the full path if needed.