I’m developing a C# asp.net web application. I’m basically done with it, but I have this little problem. I want to save xml files to the “Users” folder within my project, but if I don’t psychically hard code the path “C:……\Users” in my project it wants to save the file in this “C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\Users” folder, this is an annoying problem because I can’t use the hard coded directory on our web hosts server. Also, I have a checkbox list that populates from the the “DownloadLibrary” folder in my project, and its suppose to download the files from that fold but its also looking to the “C:\Program Files (x86)\Common Files\microsoft shared\DevServer\10.0\” folder for download even though its populating from the correct folder. I’m very confused by this, its the first time something like this has ever happened to me. Can anyone please help me with this, its the only thing standing in my way to complete this project.
Share
You don’t want to use the working directory at all; you want to use a directory relative to where the web application is located (which can be retrieved from
HttpRequest.ApplicationPath.Update
As VincayC points out; asp.net development is not my strongest skill 😉 The above code is essentially equivalent of this (much simpler) code:
If this code appears in the code-behind of a page, you can probably cut
HttpContext.Currentas well, since the page has aRequestproperty.