![]() |
|
|
|||||||
![]() |
ASP Net - automatically copy data file to root directory, asp.net |
|
|
Thread Tools | Search this Thread |
|
|
#1 |
|
Posts: n/a
|
hi,
this might be a simple one to them who know: i'm developing an asp.net project and use the debug mode. i have a xml file which contains data, that shall be read, if a specific page is run. when i build the project the file is correctly copied to the build location (i selected "build action: none" and "copy if newer"). but when the project is run, the xml file is missing at the directory from which the site is executed. it does not get copied there automatically. in my case the directory where the site is executed is "c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\" what do i have to do, so the file is available in the the directory where the site is executed at execution time? thanks in advance, arthur |
|
|
|
#2 |
|
Posts: n/a
|
re:
!> what do i have to do, so the file is available in the !> directory where the site is executed at execution time? Is there anything stopping you from using the App_Data folder to store your application's XML data ? It's much safer than storing an XML file in the root directory, anyway, since XML files in the App_Data directory are not served to clients, even if requested directly. If you store your XML files in the App_Data directory, all you have to do is check the "Include files from the App_Data folder" option when publishing your website. VS will upload your XML data files to the App_Data directory. Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Arthur" <> wrote in message news:47c05d2e-0a50-404c-b327-... > hi, > > this might be a simple one to them who know: > > i'm developing an asp.net project and use the debug mode. i have a xml > file which contains data, that shall be read, if a specific page is > run. when i build the project the file is correctly copied to the > build location (i selected "build action: none" and "copy if newer"). > but when the project is run, the xml file is missing at the directory > from which the site is executed. it does not get copied there > automatically. in my case the directory where the site is executed is > > "c:\Program Files\Microsoft Visual Studio 9.0\Common7\IDE\" > > what do i have to do, so the file is available in the the directory > where the site is executed at execution time? > > thanks in advance, > arthur |
|
|
|
#3 |
|
Posts: n/a
|
Hi,
thanks for your answers. @juan & mark: i put the file in the App_Data folder. now the folder gets copied to the build location on compilation, but is still not available when running the project on the local computer in debug mode. its just the exception message changed from "file not found" to "folder not found". @patrice: it must be a webproject as it starts a local server and iexplorer to view the site. lets put it that way: how would you add a content file, you want to read from a class that is implemented in one of your websites? it should be in the project or App_Data folder, i want to edit it there and it shall be avail at runtime, when testing in debug mode on an local instance of iis. you are surely not going to publish the whole site everytime you want to test it while devloping, are you? eg: page_load in index.aspx.cs wants to open file "App_Data\content.xml" and read from it. what do i have to do, that "content.xml" is available in whatever directory, the site is copied to, when running it locally by pressing F5? this has to be easy! - lol - if not, its typically microsoft |
|
|
|
#4 |
|
Posts: n/a
|
re:
!> how would you add a content file, you want to read from !> a class that is implemented in one of your websites? DataSet mydata = new DataSet(); mydata.ReadXml(Server.MapPath("~/App_Data/content.xml")); Juan T. Llibre, asp.net MVP asp.net faq : http://asp.net.do/faq/ foros de asp.net, en español : http://asp.net.do/foros/ ====================================== "Arthur" <> wrote in message news:d9d989c3-4f68-43f0-a7a3-... > Hi, > > thanks for your answers. > > @juan & mark: > > i put the file in the App_Data folder. now the folder gets copied to > the build location on compilation, but is still not available when > running the project on the local computer in debug mode. its just the > exception message changed from "file not found" to "folder not found". > > @patrice: > > it must be a webproject as it starts a local server and iexplorer to > view the site. > > > lets put it that way: > how would you add a content file, you want to read from a class that > is implemented in one of your websites? it should be in the project or > App_Data folder, i want to edit it there and it shall be avail at > runtime, when testing in debug mode on an local instance of iis. you > are surely not going to publish the whole site everytime you want to > test it while devloping, are you? > > eg: > page_load in index.aspx.cs wants to open file "App_Data\content.xml" > and read from it. > > what do i have to do, that "content.xml" is available in whatever > directory, the site is copied to, when running it locally by pressing > F5? > > this has to be easy! - lol - if not, its typically microsoft |
|
|
|
#5 |
|
Posts: n/a
|
Great,
Server.MapPath("...") works for me. Thanks very much! Art |
|
![]() |
| Thread Tools | Search this Thread |
|
|
Similar Threads
|
||||
| Thread | Thread Starter | Forum | Replies | Last Post |
| viewstate MAC failed in asp.net 2.0 while postback the page | azraffarveen | Software | 0 | 05-12-2009 02:24 PM |
| .NET 2.0 Web Apps / .NET 3.5 ASP.NET Apps - Differences/Similariti | london1919 | MCTS | 1 | 12-08-2008 02:16 PM |
| ASP.NET: Asign Users in Roles(Array.IndexOf(Of String) method) | msandlana | Software | 0 | 04-25-2008 05:37 AM |
| Impersonation in ASP.net 1.1 on IIS 5.0 | sitaramig | Software | 0 | 05-30-2007 12:34 PM |
| ASP.NET 2.0 application does not run in WIN2k3 | johnfraj | Software | 0 | 04-19-2007 07:27 AM |