-1

#Get current Assembly information through Reflection.

protected static string GetCurrentFolder()
{
    string codeBase = Assembly.GetExecutingAssembly().CodeBase;
    UriBuilder uri = new UriBuilder(codeBase);
    string path = Uri.UnescapeDataString(uri.Path);
    return Path.GetDirectoryName(path);
}  
Dev-lop-er
  • 578
  • 1
  • 7
  • 16

1 Answers1

0
  • Access folder after get the current assembly information.
  • Add folder in the corresponding path first.
 var file = File.ReadAllText(Path.Combine(GetCurrentFolder(), @"Documents\Template.html"));

#Without Reflection you can use the below command,but make sure you copy the file in bin -> debug folder Set the property of file Copy to Output Directory as "Copy Always" from visual studio.(Create a folder for your document as paste the file in visual studio)

File.OpenRead(Path.Combine(
                AppDomain.CurrentDomain.BaseDirectory, @"Documents\Template.html"));
Dev-lop-er
  • 578
  • 1
  • 7
  • 16