Vote count: 0
I have an asp.net application Site1 in this folder
I'd like to access from the Site1 to a file in Application1 folder so I tried this code
var webRootPath = _env.WebRootPath;
string[] nwpath = webRootPath.Split('\\');
string s = "";
for (int i = 0; i < nwpath.Length - 2; i++)
{
if (i == nwpath.Length - 3) s += nwpath[i];
else s += nwpath[i] + "\\";
}
var webSrcPath = s + @"\Application1";
string path1 = Path.Combine(webSrcPath, @"Views\Shared\{0}.cshtml");
string path2 = path1.Replace(@"\", @"//");
var isExists1 = File.Exists(path1);
var isExists2 = File.Exists(path2);
The two paths are the same
C:\Users\use\Documents\Visual Studio 2015\Projects\DeployNetCore\Application1\Views\Home_LayoutApp1.cshtml
the file exists but
- I get an exception indicates that the file is not located !!
- The booleans are false !!
So, How can I fix this issue?
asked 25 secs ago
File not located using a c# application
Aucun commentaire:
Enregistrer un commentaire