views:

254

answers:

1

I currently am loading all images in a folder in my "MyPictures" folder on my machine which works fine...

foreach (string filename in Directory.GetFiles(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)))

What I really want to be able to do, though, is load all the images in my Images folder within my solution project. Can someone please tell me the correct syntax to do this?

Thanks! Todd

A: 

[Nothing in your question (as it is currently stated) is really directly related to WPF as opposed to C# (and Windows development) in general, as far as I can tell. You might get a better reply if the question was tagged to C# as opposed to just WPF.]

I don't think there is a way to reference your solution's folder as such (nor does it really make much sense, as the users of your application won't in general have the solution, only the distributables).

If you need the directory to be within your solution folder somehow, maybe you should refer to the directory your executable resides in (...\SolutionDir\bin\Debug), which you can get using

System.IO.Path.GetDirectoryName(
    System.Reflection.Assembly.GetExecutingAssembly()
    .GetModules()[0].FullyQualifiedName);

(Of course, you could tack \..\.. to that to refer to the SolutionDir instead, but that'd be a bit ugly.)

Depending on the usage of the images, though, it'd probably be better to put them under one of the defined special directories -- Environment.SpecialFolder.CommonApplicationData sounds like the best candidate, if the images are to be shared by all users.

TomiJ