View content of a .resource file - c#

I have a .NET executable and I need to view the resources attached to it. I extracted .resource file from .NET executable using DotNetResourcesExtract utility but I don't now how to view content of .resource file.
Could someone explain how to view this file?

Not sure you're using it correctly...
Assuming your storing images there.
You can simply do:
Image resfile = ProjectName.Properties.Resources.resourceName;
So if resfile is an image, you can put it into an Image control.
so, if you have an image control on your form you can simply do:
imageControl.Image = ProjectName.Properties.Resources.resourceName;
If it's a text file or any other type of file - again, you can access it the same way. If it's a binary file, the ProjectName.Properties.Resources.resourceName will be a byte array, so you 'll need to load it in the correct manner.
Is that what you're wanting? Otherwise indicate what type of file are you trying to extract from your resource file.

According to MSDN The .resx (XML-based resource format) files are
converted into common language runtime binary .resources files
that can be embedded in a runtime binary executable or compiled into
satellite assemblies.
Getting to the point: How to view this?
Well, Since it's a binary file which contains resource(images etc.) therefore you could always use Windows resources editing/extracting applications.
eg. Restorator, Resource Hacker to name a few.
Meanwhile, have look at this Stackoverflow post. which sound almost similar.

Related

C# Wpf embed images at runtime

In my C# WPF application the user have the possibility to import pictures.
Currently the source of the image is referenced to the picture path.
When the picture will be deleted or moved, then my reference is not valid anymore.
How is it managed in applications like Word or Photoshop? Is it possible to embed
the picture at runtime in my custom file? Or should these files copied to a
"image database"?
In Microsoft Word (docx) format. When you paste images in the document, it saves them as file(s). Try this:
Rename the .docx to .zip extension
Extract the zip archive
Now, navigate to the following and you can see all the embeded images here:
You can do something similar for your app. Without knowing the full context and design details its difficult to answer where should the images go.
Generally speaking, images should/could be co-located with the rest of the data that image compliments.

How to programmatically determine if an image file is georeferenced

I have a task to programamatically scan a folder for georeferenced images. There might be a lot of images, some quite large, and some not georeferenced. The spatial information can also be either embedded or in a world file.
How can I tell programmatically (C#/WPF/ESRI Runtime) if "C:\someFolder\file.x" is georeferenced?
Thanks
First check the file type to see if it's a format that supports built in georeferencing (GeoTiff, jp2, and MrSid). Other static image files would need some sort of companion file with the georeferencing information. So for each image file you'd want to look for a matching companion file.
If you add some info on what formats the images/world files are in it'll be easier to show you some sample code.

Include editable file in c# .exe

I would like to embed a .txt file into my C# project storing a list values for the user. These values should be configurable and therefore the .txt will have to be edited during runtime. I have found out that Embedded Resources cannot be modified. Is there any other way to do that?
Thank you.
Store the text file as an embedded resource. The first time your program is run, copy the embedded resource to a file on disk, and use it for the configuration. Your users can edit the disk file.
The embedded resource version serves as a default configuration.
You can use your app.config or web.config configuration files.
Normall if you will use large amout of data using a database is recommended. I assume you really need just a .txt document. In your assembly write a procedure that will create that text file if its not present. To be more specific lets say your program is mainProgram.exe. In onload event of mainprogram.exe write a procedure checkTxtFile(). This procedure first will check if there is a txt file in the directory.If the file is not presend it will create it with the desired values.
You can create a XML file using Filestream and using it during runtime or
make your own protocol format and store the data in the file so that no one can change it.
Over to that you can also encrypt and decrypt the file on the fly.
Lists of modifyable, persistable values are best stored in a database. There are many lightweight options to choose from; in this case I think a SqlLite database would suit your purposes best.

Images from common project

I have 4 projects in same solution. In one project the images get uploaded & stored in some folder.Now I want to show this image in another project which is in same solution.What code should I write in C#?
It seems to me that it would be sensible that the same project responsible for storing the images should be responsible for retrieving them too... either by providing a filename "mapping" service (e.g. original upload filename mapped to physical location on disc) or by giving a method which will open the file and return a Stream to the data. Then showing the image becomes a matter of calling that method and then loading the image as normal.
It's hard to be more precise without more details of what you're trying to do, how the image is stored etc. What have you already tried, and what problems have you run into?
You can keep the ImageFolder path in config file in all the project.
And that path can be use to Read/Write the image(s).

RESX files and xml data

What is the best way to store XML data used in a program ? Use RESX file or store it as a .xml file and load and unload the files as per requirement
A third option would be to put the XML file as embedded resource in the assembly. In that case, use Assembly.GetManifestResourceStream() to load the XML.
As Cerebrus wrote, when localization is necessary, RESX would be the way to go.
.resx files are XML files albeit conforming to a particular schema (Microsoft ResX Schema v2.0). This schema was designed with the explicit aim of being easily human readable and editable manually.
I see no problem with storing your data as XML files. Basically it depends on the function of the data - If it is localizable resources that you are trying to store, go with the established .resx files. If not, you are free to use your XML with custom schema.
Putting XML (blobs) in .resx
Positives:
Readily available
Negatives:
It would increase the memory load, if the content is big in size. Big-in-size is in comparison to assembly size without content. If an assembly size is 10kb and content size is 10kb, even though 10kb is not bigger in today's scenario, one can reduce assembly size to half just by keeping content in separate file.
Code manageability goes to down drastically, by keeping XML as string Key-value-pairs in
RESX. As resx editor is not be XML sensitive.
If one is very keen keeping xml content as embedded resource, you can create XML file and keep it as file resource inside RESX.

Categories

Resources