Server.MapPath

J

Jim Heavey

I am trying to set up the "path" for were my Access Database is on my
Webhost provideer. When I set up my FTP account, it indicated that my
physical path was "E:\www.MyWebsite.com".

When I asked my webhost if I could use this as my physical address, they
indicated that I should create a directory under the root and place my
access database there and the use the "Server.MetPath(string)" to retrieve
the path.

My question is what value do I place in the "String" portion of the method.
I am guessing that I would put "www.MyWebsite.com/MyDataFolder". Is that
correct?

If that is correct, then how will I be able to modify my code to work on my
test machine and work on the production box without changes? I would guess
that I would use "localhost" or my IP address, but that would not be the
same for when I move the code to the production box. I guess I could place
the value in the web.config file, but is there a better way to do this?

Thanks in advance for your assistance!!!!!!!!!!!!
 
M

Marshal Antony

Hi Jim,
You will need to use Server.MapPath not Server.MetPath
In your website say http://www.MyWebsite.com/MyDataFolder
,MyDataFolder is the virtual path.
To translate this virtual path into the actual physical path you need to use
Server.MapPath.
It will be like : Server.MapPath("MyDataFolder") which will give you
the physical path.
The output of this will be like E:\www.MyWebsite.com\MyDataFolder which is
the actual physical path.

Hope this helps.
Regards,
Marshal Antony
..NET Developer
http://www.dotnetmarshal.com
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,774
Messages
2,569,598
Members
45,149
Latest member
Vinay Kumar Nevatia0
Top