physical path to virtual path under virtual directory

Discussion in 'ASP .Net' started by =?Utf-8?B?SmVmZiBCZWVt?=, Aug 1, 2007.

  1. 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.
    =?Utf-8?B?SmVmZiBCZWVt?=, Aug 1, 2007
    #1
    1. Advertising

  2. What about

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

    ?

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


    "Jeff Beem" <> wrote in message
    news:...
    > 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, Aug 1, 2007
    #2
    1. Advertising

  3. 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.ApplicationPath), "");
    >
    > ?
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Jeff Beem" <> wrote in message
    > news:...
    > > 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.

    >
    >
    >
    =?Utf-8?B?SmVmZiBCZWVt?=, Aug 1, 2007
    #3
  4. 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.ApplicationPath), "");
    >
    > ?
    >
    > --
    > Eliyahu Goldin,
    > Software Developer
    > Microsoft MVP [ASP.NET]
    > http://msmvps.com/blogs/egoldin
    > http://usableasp.net
    >
    >
    > "Jeff Beem" <> wrote in message
    > news:...
    > > 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.

    >
    >
    >
    =?Utf-8?B?SmVmZiBCZWVt?=, Aug 1, 2007
    #4
  5. 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" <> wrote in message
    news:...
    > 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.ApplicationPath), "");
    >>
    >> ?
    >>
    >> --
    >> Eliyahu Goldin,
    >> Software Developer
    >> Microsoft MVP [ASP.NET]
    >> http://msmvps.com/blogs/egoldin
    >> http://usableasp.net
    >>
    >>
    >> "Jeff Beem" <> wrote in message
    >> news:...
    >> > 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, Aug 1, 2007
    #5
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Jack Wright
    Replies:
    1
    Views:
    459
    sonikchopra
    Apr 19, 2005
  2. Steve Singer
    Replies:
    0
    Views:
    526
    Steve Singer
    Feb 15, 2005
  3. marss
    Replies:
    5
    Views:
    991
    marss
    Sep 13, 2007
  4. Scott Tilton

    Convert Physical path to Virtual path?

    Scott Tilton, Jul 11, 2003, in forum: ASP General
    Replies:
    2
    Views:
    601
    Dhananjay Modak
    Jul 11, 2003
  5. Guest

    Virtual Path and physical root

    Guest, Aug 2, 2004, in forum: ASP General
    Replies:
    4
    Views:
    207
    Guest
    Aug 2, 2004
Loading...

Share This Page