Getting File Path
-
in application root i have a xml file. how can i get that file path. i am using to get file path @"..\..\file name,xml" when i run it from vs it is working. but when i Publish it it through an error. error shows file not found. how i will solve my problem can any one tell me. thanks
-
in application root i have a xml file. how can i get that file path. i am using to get file path @"..\..\file name,xml" when i run it from vs it is working. but when i Publish it it through an error. error shows file not found. how i will solve my problem can any one tell me. thanks
Ajeet mittal wrote:
in application root i have a xml file. how can i get that file path. i am using to get file path @"..\..\file name,xml"
That is not the application root. That is two levels above the application root.
Ajeet mittal wrote:
when i run it from vs it is working.
That is because the XML file is most likely in your project, not the application root.
Ajeet mittal wrote:
how i will solve my problem
Don't hard code file paths (relative or absolute) in your application. Put file paths in the config file and find out from there. Also, if the XML files are supposed to be in the application root folder then you might want to tell Visual Studio that so that it can copy the XML files to that location when you run your application. To do that, right click the XML file in the Solution Explorer. Select "Properties" in the context menu. In the Properties ensure that "Build Action" is set to "Content" and that "Copy to Output Directory" is set to either "Copy if newer" or "Copy Always"
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
-
Ajeet mittal wrote:
in application root i have a xml file. how can i get that file path. i am using to get file path @"..\..\file name,xml"
That is not the application root. That is two levels above the application root.
Ajeet mittal wrote:
when i run it from vs it is working.
That is because the XML file is most likely in your project, not the application root.
Ajeet mittal wrote:
how i will solve my problem
Don't hard code file paths (relative or absolute) in your application. Put file paths in the config file and find out from there. Also, if the XML files are supposed to be in the application root folder then you might want to tell Visual Studio that so that it can copy the XML files to that location when you run your application. To do that, right click the XML file in the Solution Explorer. Select "Properties" in the context menu. In the Properties ensure that "Build Action" is set to "Content" and that "Copy to Output Directory" is set to either "Copy if newer" or "Copy Always"
Recent blog posts: * Introduction to LINQ to XML (Part 1) - (Part 2) - (part 3) My website | Blog
Thanks I do it what u told. but when i deploy my project.i still got error message. File not found. can u tell me the solution. what i have to do. thanking u
-
Thanks I do it what u told. but when i deploy my project.i still got error message. File not found. can u tell me the solution. what i have to do. thanking u