I have one .net windows application I'm trying to read .xml file from c# windows application.
but i'm getting error :
Could not find a part of the path 'c:\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\~\Files\test.xml'.
but my file is in Files folder which is in application WindowsFormsApplication1 only
not in \bin\Debug
then why it is searching into \bin\Debug ?
code in form.cs
DataSet dsAuthors = new DataSet("authors");
string filePath = @"~/Files/test.xml";
dsAuthors.ReadXml(filePath);
also please tell me is there any way to use Server.MapPath like we do it in web application.
I tried other solution like :
string appPath = Path.GetDirectoryName(Application.ExecutablePath);
System.IO.DirectoryInfo directoryInfo = System.IO.Directory.GetParent(appPath);
System.IO.DirectoryInfo directoryInfo2 = System.IO.Directory.GetParent(directoryInfo.FullName);
string path = directoryInfo2.FullName + @"\Files";
but getting error :
Access to the path is denied.