473,666 Members | 2,038 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

How to get virtual path of a folder on a server independent of where it is reside.

Hello friends,

I have one folder Named as MainFolder on server. I have one more
folder named as subfolder inside tht main folder.Now I want to save
some pictures in tht folder but at runtime I m not getting correct
virtual path of tht folder. As Server.MapPath( ) & MapPath methods
returns physical path.So How I can Access tht folder independent of
where my application is insatlled.
I have used following metthods but it doesnt work,

Server.MapPath( ".//subfolder");
MapPath("~/subfolder");
Request.MapPath (".//subfolder");

Thxxxxxxx,
Sachin.

Dec 25 '06 #1
1 3806
Hi Sachin,

You can create a virtual path by simply concatenating strings that represent
the known paths:

string root = "~/";
string basePath = "folder/";
string filePath = "subfolder/file.ext";

string path = root + basePath + filePath;

This produces a virtual path that is independent of the physical location of
your application:

~/folder/subfolder/file.ext

If I don't exactly understand your question they you can try rephrasing it
and providing more detail. You may want to take a look at this as well:

VirtualPathUtil ity Class
http://msdn2.microsoft.com/en-us/lib...thutility.aspx

--
Dave Sexton
http://davesexton.com/blog

<gu************ *@gmail.comwrot e in message
news:11******** *************@4 2g2000cwt.googl egroups.com...
Hello friends,

I have one folder Named as MainFolder on server. I have one more
folder named as subfolder inside tht main folder.Now I want to save
some pictures in tht folder but at runtime I m not getting correct
virtual path of tht folder. As Server.MapPath( ) & MapPath methods
returns physical path.So How I can Access tht folder independent of
where my application is insatlled.
I have used following metthods but it doesnt work,

Server.MapPath( ".//subfolder");
MapPath("~/subfolder");
Request.MapPath (".//subfolder");

Thxxxxxxx,
Sachin.

Dec 26 '06 #2

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

Similar topics

0
1387
by: Joe | last post by:
I've been running into problems when trying to create a Virtual FTP folder in ASP.Net. I've tried it a few ways but none of them has worked so far. I have identity impersonation turned on, and the current user is an administrator on the machine, so I wouldn't think it's a permissions issue, but I can't think of anything else that it might be. The first way I tried, which worked fine in ASP but not ASP.Net, is: Dim Path Dim ftpSvc Dim...
2
4221
by: Jeffry van de Vuurst | last post by:
Hi, (sorry for the crosspost, I wasn't sure which was the best place to put this). I was just thinking about something and wondered if any of you has some ideas about this. I'm using the NetAdvantage component suite from Infragistics for my web applications. When installing they create several virtual
5
1233
by: moondaddy | last post by:
I'm setup with a new ISP where we were given an account which we could setup multiple domains. To do this we were given a root directory where we setup a folder for each domain. then we mapped the folders to virtual domains. Then I copied a VS 2003 project (an old front page website that was turned into a VS project for this process) by using the Copy Project menu to its new location in one of these virtual domains. When I surf to the...
2
2637
by: flat_ross | last post by:
Hi, I am in a shop where developers are required to work off of a network share. This is so that code is backed up nightly. So I am testing running an ASP.NET Web application with a Class assembly all on a shared drive. I have the solution working perfectly. However, I have run into a hiccup. In order to map IIS Virtual Dir to a network drive, you need
11
2314
by: ASP.NET User | last post by:
Hi I am in a shop where developers are required to work off of a networ share. This is so that code and other documentation is backed up nightly. This is outside the realm of Visual SourceSafe which we also use for code control. The network drive is used as the working folder. This is a configuration this shop has used for 6 years and I do not see it changing any time soon So I am testing running an ASP.NET Web application with a Clas...
8
3383
by: nick | last post by:
I have a problem and I've been using a cheezy work around and was wondering if anyone else out there has a better solution. The problem: Let's say I have a web application appA. Locally, I set it up as C:\domains\appA. Locally, my IIS root points to C:\domains. I don't point it to C:\domains\appA since if I have an appB under C:\domains I wouldn't be able to get to it. So to access it via my browser I go to localhost/appA.
14
12710
by: Lorenzo | last post by:
Hello, I have a web application with a virtual directory in it. With 'virtual directory' i mean a folder whose physical path is different from the physical path of the application, but in which Web Sharing is active. For example: my application is in "C:\Inetpub\wwwroot\MyApp", the Virtual folder is in "C:\VirtualFolder", and IIS sees it as if it were in "C:\Inetpub\wwwroot\MyApp\VirtualFolder".
2
4788
by: pappu | last post by:
Hello friends, I have one folder Named as MainFolder on server. I have one more folder named as subfolder inside tht main folder.Now I want to save some pictures in tht folder but at runtime I m not getting correct virtual path of tht folder. As Server.MapPath() & MapPath methods returns physical path.So How I can Access tht folder independent of where my application is insatlled. I have used following metthods but it doesnt work,
4
3327
by: tshad | last post by:
I have a site www.stf.com and a site www.stfstage.com (where I do all my testing). The problem is that www.stfstage.com is only internal and I need to get access from the outside (without creating a new domain). I tried to create a Virtual directory inside my stf site so that I would access it like: www.stf.com/stage/. I run as www.stfstage.com fine and have for a long time.
1
8551
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
7386
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then launch it, all on its own.... Now, this would greatly impact the work of software developers. The idea...
1
6198
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules. He will explain when you may want to use classes instead of User Defined Types (UDT). For example, to manage the data in unbound forms. Adolph will...
0
5664
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
4198
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The last exercise I practiced was to create a LAN-to-LAN VPN between two Pfsense firewalls, by using IPSEC protocols. I succeeded, with both firewalls in the same network. But I'm wondering if it's possible to do the same thing, with 2 Pfsense firewalls...
0
4368
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
2771
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
2011
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.
2
1775
bsmnconsultancy
by: bsmnconsultancy | last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating effective websites that not only look great but also perform exceptionally well. In this comprehensive...

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.