How to read xml file in .net windows application in different directory?

chachawpi

New Member
I have one .net windows application I'm trying to read .xml file from c# windows application.but i'm getting error :\[quote\] Could not find a part of the path 'c:\WindowsFormsApplication1\WindowsFormsApplication1\bin\Debug\~\Files\test.xml'. \[/quote\]but my file is in \[code\]Files\[/code\] folder which is in application \[code\]WindowsFormsApplication1\[/code\] onlynot in \[code\]\bin\Debug\[/code\]then why it is searching into \[code\]\bin\Debug\[/code\] ?code in form.cs \[code\]DataSet dsAuthors = new DataSet("authors"); string filePath = @"~/Files/test.xml"; dsAuthors.ReadXml(filePath);\[/code\]also please tell me is there any way to use Server.MapPath like we do it in web application.I tried other solution like :\[code\]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";\[/code\]but getting error :\[code\]Access to the path is denied.\[/code\]
 
Back
Top