Velocity Reviews - Computer Hardware Reviews

Velocity Reviews > Newsgroups > Programming > ASP .Net > physical path to virtual path under virtual directory

Reply
Thread Tools

physical path to virtual path under virtual directory

 
 
=?Utf-8?B?SmVmZiBCZWVt?=
Guest
Posts: n/a
 
      08-01-2007
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.
 
Reply With Quote
 
 
 
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-01-2007
What about

myPhysicalPath.Replace(Request.MapPath(Request.App licationPath), "");

?

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


"Jeff Beem" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.



 
Reply With Quote
 
 
 
 
=?Utf-8?B?SmVmZiBCZWVt?=
Guest
Posts: n/a
 
      08-01-2007
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

"Eliyahu Goldin" wrote:

> What about
>
> myPhysicalPath.Replace(Request.MapPath(Request.App licationPath), "");
>
> ?
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Jeff Beem" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.

>
>
>

 
Reply With Quote
 
=?Utf-8?B?SmVmZiBCZWVt?=
Guest
Posts: n/a
 
      08-01-2007
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.

"Eliyahu Goldin" wrote:

> What about
>
> myPhysicalPath.Replace(Request.MapPath(Request.App licationPath), "");
>
> ?
>
> --
> Eliyahu Goldin,
> Software Developer
> Microsoft MVP [ASP.NET]
> http://msmvps.com/blogs/egoldin
> http://usableasp.net
>
>
> "Jeff Beem" <(E-Mail Removed)> wrote in message
> news:(E-Mail Removed)...
> > 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.

>
>
>

 
Reply With Quote
 
Eliyahu Goldin
Guest
Posts: n/a
 
      08-01-2007
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.

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


"Jeff Beem" <(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> 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.
>
> "Eliyahu Goldin" wrote:
>
>> What about
>>
>> myPhysicalPath.Replace(Request.MapPath(Request.App licationPath), "");
>>
>> ?
>>
>> --
>> Eliyahu Goldin,
>> Software Developer
>> Microsoft MVP [ASP.NET]
>> http://msmvps.com/blogs/egoldin
>> http://usableasp.net
>>
>>
>> "Jeff Beem" <(E-Mail Removed)> wrote in message
>> news:(E-Mail Removed)...
>> > 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.

>>
>>
>>



 
Reply With Quote
 
 
 
Reply

Thread Tools

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
How get the virtual path based on the physical path? marss ASP .Net 5 09-13-2007 04:20 PM
Session is lost if a directory is created under virtual directory Jack Wright ASP .Net 1 04-19-2005 03:04 PM
virtual directory name? or unc directory path? Steve Singer ASP .Net 0 02-15-2005 10:26 PM
Virtual Path and physical root ASP General 4 08-02-2004 08:31 PM
Convert Physical path to Virtual path? Scott Tilton ASP General 2 07-11-2003 03:14 PM



Advertisments