473,387 Members | 1,606 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,387 software developers and data experts.

Server.Mappath() method

Hello,

I used Server.MapPath(mypath) method to find an absolute
path of a file on a web server. But I got error message -
Name 'Server' is not declared. I have imported System.IO.
Does someone know any tricky here?

Thanks in advance.

Jane
Jul 21 '05 #1
2 3922
Jane,
I used Server.MapPath(mypath) method to find an absolute
path of a file on a web server. But I got error message -
Name 'Server' is not declared. I have imported System.IO.
Does someone know any tricky here?


Where's your code located? Server is a property of the
System.Web.UI.Page class so you have to put the code inside your page
class, or pass a reference to the Page object to the method where you
want to use Server.MapPath.

System.IO has nothing to do with it.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.com
Please reply only to the newsgroup.
Jul 21 '05 #2
Thanks so much, Mattias.

I am developing a windows application that checks if a
particular web page is on the web server. When I use
system.IO.File.Exists(path) method to check it, path
parameter has to be an absolute path. But I only know
virtual path. Is there any other methods I can use to find
an absolute path of a web page in a windows application?

Jane

-----Original Message-----
Jane,
I used Server.MapPath(mypath) method to find an absolute
path of a file on a web server. But I got error message - Name 'Server' is not declared. I have imported System.IO. Does someone know any tricky here?
Where's your code located? Server is a property of the
System.Web.UI.Page class so you have to put the code

inside your pageclass, or pass a reference to the Page object to the method where youwant to use Server.MapPath.

System.IO has nothing to do with it.

Mattias

--
Mattias Sjögren [MVP] mattias @ mvps.org
http://www.msjogren.net/dotnet/ | http://www.dotnetinterop.comPlease reply only to the newsgroup.
.

Jul 21 '05 #3

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

6
by: Dan Sikorsky | last post by:
How do you use server.mappath to update a access database on a completely different computer? One of my websites needs to update a database on a completely different website. Example: My ASP...
4
by: Glenn M | last post by:
I have a shared XML file on a server . i also have one xslt file that performs a simple transform on in to view the data. now i want to have another page that lets users modify the shared xml...
6
by: Nathan Sokalski | last post by:
When using the Server.MapPath() method, the results being returned are given as locations on my hard drive. I would like to be returned a result that is a URL, in my case something like the...
6
by: darrel | last post by:
I have some functions that are reading/writing to the file system. As such, they use server.mapPath a lot to navigate it all. Since I'm using these functions numerous times throughout my...
3
by: Cozmo | last post by:
We have an .asp application , located in: e:\myapp In there we have directories like: e:\myapp\db e:\myapp\images e:\myapp\utils e:\myapp\working
7
by: teo | last post by:
I need to use the 'Server.MapPath' function in the 'Session_End' event of the Global.asax file (to reach a folder and the clean some temporary files up), but it doesn't work: Sub...
5
by: MichiMichi | last post by:
When using Server.MapPath on IIS 5 on my localhost everything works well. All of the following commands are executed without any error Response.Write(Server.MapPath("/app_test") & "<br>")...
4
by: vunet.us | last post by:
How to use server.mappath() parent folder correctly: Server.MapPath("../test.asp") Thank you for the hint.
3
by: rn5a | last post by:
Server.MapPath returns the physical file path that corresponds to the specified virtual path whereas Request.MapPath maps the specified virtual path to a physical path. Assuming that a file named...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.