tags:

views:

33

answers:

1

Good day all,

In my application I am allowing the user to browse their computer for an image. I then want to copy the selected file to a directory ("Images") within the application. This is what is causing me trouble.

I tried using string root = AppDomain.CurrentDomain.BaseDirectory; to find the root and then navigate to my "Images" folder from there but i am getting a DirectoryNotFoundException.

How would one go about finding this directory that is with in my applications root?

Thanks, Kohan.

+1  A: 

I hope I understood you correctly. Your application runs in some directory, and you're looking for a subdirectory named "Images":

var assemblyLocation = Assembly.GetExecutingAssembly().Location;
var applicationDirectory = Path.GetDirectoryName(assemblyLocation);
var imagesDirectory = Path.Combine(applicationDirectory, "Images");
Elisha
Works great, i was getting some weirdness on Path though. It was looking in System.Windows.Shapes. I had to use : System.IO.Path. Guess i could have just deleted the Shapes namespace. Many thanks non-the-less.
Kohan