I want to access my folder that contains Image files.
The folder is located inside my project. Here is the look on my Explorer:
[
]
I am not able to access it through code when I do the following: Vanilla_Icons_Installer.Images.
How can I access Image1.png inside Images folder by doing PreviewPicture.Image = path?
In WPF you can use a relative path inside your XAML like this:
<Image x:Key="Image" Source="../Images/Image1.png" />
But in your screenshot I see that you are using WinForms and you want to set it through code.
Therefore you could try this:
PreviewPicture.Image = Image.FromFile(
Path.Combine (
Path.GetDirectoryName (Assembly.GetExecutingAssembly().Location),
"Images/Image1.png"));
Don't forget to set the Copy to Output directory option to e.x. "Copy if newer" for your Image file.
The above code will create a Images directory in your bin/debug folder with the image inside.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With