Loading Bitmap using Relative File Path
See original GitHub issueBefore #2104, it is able to use the relative path for Image
<Image Width="16" Height="16" Source="Images/File.png" />
(mak sure Directory.SetCurrentDirectory(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));
first)
, where File.png is a Content that will copy to output directory. Currently, It throws a error of :
System.ArgumentException: Relative uris for 'resm' scheme aren't supported; resm:SampleApp.MainWindow.xaml?assembly=SampleApp uses resm
.
However, it still is able to load the image with relative path by
Bitmap image = new Bitmap("Images/File.png");
Issue Analytics
- State:
- Created 5 years ago
- Comments:10 (6 by maintainers)
Top Results From Across the Web
c# - Relative Path when creating Bitmap
I am trying to create a Bitmap using: bitmap = new Bitmap(@"Movies\View\Images\missing_person.bmp");. However, I am receiving a System.
Read more >wxBitmap load from file relative path
Hello, i'm new to wxWidgets and to the forum! I have a very simple question... when I load a bitmap from a file...
Read more >BitmapImage does not work with relative path image file
Hi, When I use relative path for image, the image does not show. Marker marker = new Marker(new PointShape(projection.ConvertToInternalProjection(place.
Read more >C# Bitmap only loads when static file address is specified
Start by doing two things. First, change your code slightly: C#. string fileSpec = string.Format(@".\Images\{0}\{1}.png", subfolderName, ...
Read more >Bitmaps — wxGlade 1.0.0 documentation
Specify the absolute or relative path to the bitmap file. For an absolute path, you may use the file dialog by clicking the...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
We might add Host handling for
file:
scheme. So app-relative paths would look likefile://appdir/Images/File.png
. I think hostname infile://
is never used, so it should be fine.Ok, I ended up with a mix of property and static resource binding. As a reference, here is my working demo code. Thanks again for the quick help!
And the converter class