0

.Net MVC. I want to load a XML file from my directory and the directory path can be random. I can load the XML file but I need also to know my file directory path. Can anybody give me the idea how can I get the full directory path of my XML file. Suppose the file is in C:\abc\test.xml or D:\cde\test2.xml. If I load 1st one I need the directory path as C:\abc\test.xml in my application.

6
  • 1
    If you loaded the file, don't you already have the full path?? Commented Sep 22, 2016 at 13:14
  • 1
    You want to know the full directory of the file on the client's machine? That's not really possible within the browser's sandbox. You would need additional program to run on the client's machine. Commented Sep 22, 2016 at 13:14
  • 1
    You can use Server.MapPath("~/abc//test.xml") to get directory path Commented Sep 22, 2016 at 13:16
  • @ShakirAhamed Thanks for your comment. But this one is howing "c:\\users\\hasan\\documents\\visual studio 2015\\Projects\\PPGWeb\\PPGWeb\\" directory where I don't have any test.xml file. Commented Sep 22, 2016 at 13:37
  • Which version of ASP.NET / MVC? Commented Sep 22, 2016 at 15:35

1 Answer 1

1

Sorry for my late answer. The problem was that I did not get full directory path to read the file. Then I created a cache memory to save the file and read it. It is just like, var fileSavePath = Path.Combine(Server.MapPath("~/XMLFiles"), fileName);

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.