我需要一个通过查找文件创建的 url,可以获取该文件的 url,我得到了这个:
"C:\\dev\\vsprojects\\MvcApplication4\\MvcApplication4\\hard.txt"
一切都运行良好,当我更换\\
by时问题就来了,\
但它不起作用!这是代码:
string ruta = "";
foreach (var readText in
Directory.GetFiles(@"C:\dev\vsprojects\MvcApplication4\MvcApplication4",
"stringCon.txt", SearchOption.AllDirectories))
{
ruta = readText;
}
ruta = ruta.Replace(@"\\", @"\");
//in debugger mode says ruta parameter still having
//the \\ and i cant get the content of the txt file
TextReader ReadTXT_file = new StreamReader(ruta);
//and here says that StringConexion is null, why??
string StringConexion = ReadTXT_file.ReadLine();
ReadTXT_file.Close();