Hello,

I need the path (string) of an embedded file in a Console application. I tried "Properties.Resource.file", but I got its content, not the path. Any help is appreciated.

Edited 1 Year Ago by Navee30

Do you mean inclusion files? Like System.Linq, System.IO and such?
They're located in

C:\Program Files (x86)\Microsoft Visual Studio 12.0\Common7\IDE\CommonExtensions\Microsoft

Microsoft Visual Studio 12.0, on Windows 7 x64, you can make constant variable out of that.

If you need something else, please explain it with more details.

path of an embedded file

Doesn't say much to someone who works with C# and Visual Studio. Or at least, it says not a lot to me.

Edited 1 Year Ago by Aeonix

The file is embedded in your assembly, it has no path. If you want a file you can work with outside of the resource interface, then consider GetManifestResourceStream from the assembly object for a little more control.

Hi Navee30 welcome at DaniWeb!
If you consider that your application executable is like a raisin cake, the resources are the raisins in the dough. They are embedded. Only your app knows how to reach them. There isn't a path to them, only to the application.

Comments
Mmmmm...

Thanks for the replies.

@ddanbe:
I have a text file (embedded) and I need to load it in a method ReadFile(string path). How could I do?

Edited 1 Year Ago by Navee30

I have a text file (embedded) and I need to load it in a method ReadFile(string path). How could I do?

If you take a look at the link I posted, it contains an example of reading a text file from a resource that is embedded into your assembly using the GetManifestResourceStream that deceptikon mentioned.

@ddanbe
Yes, but it is imperative that the method accepts a path as a parameter.. I cannot change it.

@djjeavons
I read the content of the link you posted, but I still get an error

Edited 1 Year Ago by Navee30

Yes, but it is imperative that the method accepts a path as a parameter.. I cannot change it.

  1. Get the stream.
  2. Create a file from that stream.
  3. You now have a path.
  4. Profit.

Yes, but it is imperative that the method accepts a path as a parameter.. I cannot change it.

Just adding to deceptikon's post (as I was going to suggest something similar), but if you really can't read it as an embedded resource due to this restriction then why is it embedded in the first place?

Application.StartupPath

Thanks!

Edited 1 Year Ago by Navee30

This question has already been answered. Start a new discussion instead.