-
Nov 3rd, 2012, 07:37 PM
#1
Thread Starter
Addicted Member
[RESOLVED] Getting the application file path for a lcal debug project
I want to get the file path for the current file in the project file. I've tried various approaches but they all point to the folder in the IIS that the site is executing in. The reason I need this is because i have an images folder in the project which needs to be accessible with a relative path to the project.
Thanks
-
Nov 3rd, 2012, 10:19 PM
#2
Re: Getting the application file path for a lcal debug project
The project is irrelevant. The project doesn't exist at run time. When you build the project the source files are compiled and transformed and the compiled output is placed in a folder. That folder is your root and that's what matters. Whether you are running in the debugger or deployed to a web server, that root folder is what matters.
I'm guessing that you're using Application.StartupPath or the like, right? That's not for web apps. Web apps are actually libraries loaded by the web server. That's why it's giving you IIS paths.
In web apps you can use "~" to represent your root folder and then go from there. If you have an Images folder under the root folder then the relative path is "~\Images". In an ASP.NET Web Forms page, you can use Server.MapPath to get the absolute path that corresponds to that virtual path.
-
Nov 4th, 2012, 06:48 AM
#3
Thread Starter
Addicted Member
Re: Getting the application file path for a lcal debug project
Originally Posted by jmcilhinney
The project is irrelevant. The project doesn't exist at run time. When you build the project the source files are compiled and transformed and the compiled output is placed in a folder. That folder is your root and that's what matters. Whether you are running in the debugger or deployed to a web server, that root folder is what matters.
I'm guessing that you're using Application.StartupPath or the like, right? That's not for web apps. Web apps are actually libraries loaded by the web server. That's why it's giving you IIS paths.
In web apps you can use "~" to represent your root folder and then go from there. If you have an Images folder under the root folder then the relative path is "~\Images". In an ASP.NET Web Forms page, you can use Server.MapPath to get the absolute path that corresponds to that virtual path.
Thanks, I got around this issue by storing the images in the App_Data folder and then getting the path that way.
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|