Home | Contact Us | FAQ | Search & Site Map | Link to Us
Sign In | Join | Other 45 Sites in Network
HomeAnnouncementsFree MagazinesWhite PapersSubmit Content
Discussion GroupsASP.NETWindows FormsLanguages.NET FrameworkVisual Studio.NET
Articles.NET FrameworkASP.NETToolsWindows Forms
.NET DirectoryOpen Source ProjectsUser GroupsWeb Resources
Related Topics
Visual Basic 6SQL ServerMS AccessOther DB ProductsMS Server ProductsMore Topics ...

.NET Forum / ASP.NET / General / August 2007

Tip: Looking for answers? Try searching our database.

physical path to virtual path under virtual directory

Thread view: 
Enable EMail Alerts  Start New Thread
Thread rating: 
Jeff Beem - 01 Aug 2007 03:18 GMT
Best way I can think to describe this is through an example.  I have a
virtual directory, let's call it "MyVirtualDirectory" that maps to
\\MyServer\Shared.  

I have a path that is \\MyServer\Shared\SomeDirectory\SomeFile.txt.

I need to convert this path to a virtual path with the virtual directory
name.  The result I'm after would be:

MyVirtualDirectory\SomeDirectory\SomeFile.txt

Any help would be greatly appreciated.
Eliyahu Goldin - 01 Aug 2007 13:36 GMT
What about

myPhysicalPath.Replace(Request.MapPath(Request.ApplicationPath), "");

?

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> Best way I can think to describe this is through an example.  I have a
> virtual directory, let's call it "MyVirtualDirectory" that maps to
[quoted text clipped - 8 lines]
>
> Any help would be greatly appreciated.
Jeff Beem - 01 Aug 2007 15:40 GMT
Sorry, but that won't do.  My web site can have one or more virtual
directories which are mapped to file storage locations.  I need the path to
have the name of the virtual directory under which the file lives as the
first part of the path.  The site itself is not a virtual directory.

Thanks

> What about
>
[quoted text clipped - 14 lines]
> >
> > Any help would be greatly appreciated.
Jeff Beem - 01 Aug 2007 15:44 GMT
My previous reply was a little off.  The site 'can be' under a virtual
directory but I'm not interested in that path.  I'm interested in the virtual
directories 'within' the site.

> What about
>
[quoted text clipped - 14 lines]
> >
> > Any help would be greatly appreciated.
Eliyahu Goldin - 01 Aug 2007 15:59 GMT
You can't tell the virtual directory by the physical path.

But, if you know the list of all your virtual directories, you can loop
through the list and use the MapPath method to match  virtual and physical
directories.

Signature

Eliyahu Goldin,
Software Developer
Microsoft MVP [ASP.NET]
http://msmvps.com/blogs/egoldin
http://usableasp.net

> My previous reply was a little off.  The site 'can be' under a virtual
> directory but I'm not interested in that path.  I'm interested in the
[quoted text clipped - 20 lines]
>> >
>> > Any help would be greatly appreciated.

Free Magazines

Get these publications absolutely FREE for up to 12 months. There are no hidden fees and no obligation. Simply choose a title, complete the application form and submit it. Read more ...

Oracle MagazineNetwork ComputingComputer WorldBio-IT WorldeWeekInformation WeekInfosecurity
 
Sign In
Join
My Latest Posts
My Monitored Threads
My Blog
My Photo Gallery
My Profile
My Homepage

Start New Thread
Enable EMail Alerts
Rate this Thread



©2008 Advenet LLC   Privacy Policy - Terms of Use
This website includes both content owned or controlled by Advenet as well as content owned or controlled by third parties.