text: Q:
  
  ReadAllText method appends file path to the application path
  
  I am using ReadAllText method to read file contents into a string but I keep getting an exception file not found. That happened because, for some reason, ReadAllText appends file path to the application path and attempts to find it:
  
  Additional information: Could not find a part of the path 'c:\Projects\MyApp1\MyApp1\bin\Debug\C\Test\MyFile.csv'.
  
  string FileName ="C:\Test\MyFile.csv";
  string allText = File.ReadAllText(fileName, encoding);
  
  How can I fix this issue?
  
  A:
  
  In C# you need to escape the \ character when you have enclosed it in a string that is enclosed in quotes.  Escaping is needed because the \ character is treated as a way of displaying special characters in a text string. Change the code to the following:
  string FileName ="C\\Test\\MyFile.csv";
  string allText = File.ReadAllText(fileName, encoding);
  
  You could also use the special @ operator to specify a verbatim string literal. That would look like the following following:
  string FileName =@"C\Test\MyFile.csv";
  string allText = File.ReadAllText(fileName, encoding);
  
  Finally, You are missing the : character in your path. The code should actually look like the following:
  string FileName = @"C:\Test\MyFile.csv";
  string allText = File.ReadAllText(fileName, encoding);
  
  