0

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 by Navee30

6
Contributors
13
Replies
51
Views
2 Years
Discussion Span
Last Post by JerrimePatient
Featured Replies
  • 1
    ddanbe 2,613   2 Years Ago

    Hi Navee30 welcome at DaniWeb! If you consider that your application executable is like a [raisin cake](http://www.bbcgoodfood.com/recipes/5396/almond-raisin-cake-with-sherry), 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. Read More

  • `Application.StartupPath` Read More

0

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 by Aeonix

0

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.

1

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.

Votes + Comments
Mmmmm...
0

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 by Navee30

0

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.

0

@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 by Navee30

0

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.
0

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?

0

Application.StartupPath

Thanks!

Edited by Navee30

This question has already been answered. Start a new discussion instead.
Have something to contribute to this discussion? Please be thoughtful, detailed and courteous, and be sure to adhere to our posting rules.