2

If I have a File Default.html in my project

alt text

How can I read it in code? I need the path

One Possible Solution

./Controls/MarkdownEditor/Templates/Default.html works too. Also I set "Copy to output directory" to "Copy if newer"

Jiew Meng
  • 84,767
  • 185
  • 495
  • 805

3 Answers3

1

Normally using this:

   Assembly.GetExecutingAssembly().GetManifestResourceStream(
            "MarkDownEditMVVM.Controls.MarkDownWditor.Templates.Default.Html");

Unless you are using special namespaces.

Aliostad
  • 80,612
  • 21
  • 160
  • 208
1

You need to set the build action for that file to "Embedded Resource" in Visual Studio (right click the file and choose properties).

Then read the file in your code like this:

Assembly asm = Assembly.GetExecutingAssembly();  
Stream stream = asm.GetManifestResourceStream(asm.GetName().Name + ".Default.html");  
Merrimack
  • 1,736
  • 14
  • 12
0

Have you had a look at AppDomain.BaseDirectory Property or AppDomainSetup.ApplicationBase Property (System)

and Path.Combine Method (String, String) to get to the directory required?

Adriaan Stander
  • 162,879
  • 31
  • 289
  • 284