Reputation: 97
[]
In my program I want to use this image (the image marked in the picture) but how can I get the path of this picture without using an absolute path (it should work on any pc without changing a path in the code)?
Can someone post a example code of opening a filestream with this picture called "Jonas.jpg"?
Upvotes: 1
Views: 273
Reputation: 161
You can get the path of your application using Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location)
and then use a Path.Combine, adding the local path.
Image.FromFile(
Path.Combine (
Path.GetDirectoryName (Assembly.GetExecutingAssembly().Location),
"Persons/Jonas.jpg"));
Upvotes: 3