how to determine if link is directory or file?

Discussion in 'ASP General' started by bart plessers, Jul 27, 2003.

  1. Hello,

    Currently I am developping a internet "directory browser"

    My page 'default.asp' has following entries:

    CurrentPATH = Request("MyLink")
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Set oFolder = oFSO.GetFolder(CurrentPATH)
    Set oFolderContents = oFolder.Files


    this works fine with 'default.asp?MyPath', where "MyPath" stands for i.e.
    c:\temp\
    but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    c:\temp\file.txt

    Is there a way to determine if the link contains a file or a path? Of course
    you can check for a dot (after dot, normaly it is an extension, thus a
    file), but I want to have it possible also to have dots in my directories...

    Anybody?


    tia!

    bartp


    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================
     
    bart plessers, Jul 27, 2003
    #1
    1. Advertising

  2. bart plessers

    Ray at Guest

    How about:

    CurrentPATH = Request.QUERYSTRING("MyLink")
    Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
    Select Case True
    Case oFSO.FileExists(CurrentPATH)
    '''you have a file
    Case oFSO.FolderExists(CurrentPATH)
    '''you have a directory
    Case Else
    '''you have nothing
    End Select
    '''etc.

    Ray at home

    --
    Will trade ASP help for SQL Server help


    "bart plessers" <> wrote in message
    news:...
    > Hello,
    >
    > Currently I am developping a internet "directory browser"
    >
    > My page 'default.asp' has following entries:
    >
    > CurrentPATH = Request("MyLink")
    > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > Set oFolderContents = oFolder.Files
    >
    >
    > this works fine with 'default.asp?MyPath', where "MyPath" stands for i.e.
    > c:\temp\
    > but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    > c:\temp\file.txt
    >
    > Is there a way to determine if the link contains a file or a path? Of

    course
    > you can check for a dot (after dot, normaly it is an extension, thus a
    > file), but I want to have it possible also to have dots in my

    directories...
    >
    > Anybody?
    >
    >
    > tia!
    >
    > bartp
    >
    >
     
    Ray at, Jul 27, 2003
    #2
    1. Advertising

  3. Hi ray!
    thanx for quick reply

    I wasn't aware of your suggested script. Nice!

    However,
    I want to have a browser based on URL, not on directorypaths,

    so

    -------------------------------------------------------
    CurrentURL = Request.QueryString("Path")
    CurrentPATH = server.mappath(CurrentURL) & "\"
    Set oFSO = CreateObject("Scripting.FileSystemObject")
    Select Case True
    Case oFSO.FileExists(CurrentPATH)
    '''you have a file
    Case oFSO.FolderExists(CurrentPATH)
    '''you have a directory
    Set oFolder = oFSO.GetFolder(CurrentPATH)
    Set oFolderContents = oFolder.Files
    Case Else
    '''you have nothing
    End Select
    -------------------------------------------------------

    gives an error on line 2 because i.e.

    path = /multimedia/2003/party/
    then CurrentPATH = D:\Inetpub\multimedia\2003\party\

    but

    path = /multimedia/2003/party/image01.gif
    then ERROR on CurrenPATH because the function server.mappath doesn't seems
    to work on files

    To avoid this problem, I should place the CurrentPATH assignment in the Case
    where my "Path" string contains a folder.
    But I need the CurrentPath in the Case-statement...

    Do you have a suggestion where I can check on URL's (not on paths) if they
    are a file or a directory?





    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:#...
    > How about:
    >
    > CurrentPATH = Request.QUERYSTRING("MyLink")
    > Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
    > Select Case True
    > Case oFSO.FileExists(CurrentPATH)
    > '''you have a file
    > Case oFSO.FolderExists(CurrentPATH)
    > '''you have a directory
    > Case Else
    > '''you have nothing
    > End Select
    > '''etc.
    >
    > Ray at home
    >
    > --
    > Will trade ASP help for SQL Server help
    >
    >
    > "bart plessers" <> wrote in message
    > news:...
    > > Hello,
    > >
    > > Currently I am developping a internet "directory browser"
    > >
    > > My page 'default.asp' has following entries:
    > >
    > > CurrentPATH = Request("MyLink")
    > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > Set oFolderContents = oFolder.Files
    > >
    > >
    > > this works fine with 'default.asp?MyPath', where "MyPath" stands for

    i.e.
    > > c:\temp\
    > > but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    > > c:\temp\file.txt
    > >
    > > Is there a way to determine if the link contains a file or a path? Of

    > course
    > > you can check for a dot (after dot, normaly it is an extension, thus a
    > > file), but I want to have it possible also to have dots in my

    > directories...
    > >
    > > Anybody?
    > >
    > >
    > > tia!
    > >
    > > bartp
    > >
    > >

    >
    >
     
    bart plessers, Jul 27, 2003
    #3
  4. bart plessers

    Ray at Guest

    Perhaps the problem is that you're adding a \ onto the end of your path, so
    you're going to wind up with something like:

    D:\Inetpub\multimedia\2003\party\image01.gif\

    Ray at home
    --
    Will trade ASP help for SQL Server help


    "bart plessers" <> wrote in message
    news:...
    > Hi ray!
    > thanx for quick reply
    >
    > I wasn't aware of your suggested script. Nice!
    >
    > However,
    > I want to have a browser based on URL, not on directorypaths,
    >
    > so
    >
    > -------------------------------------------------------
    > CurrentURL = Request.QueryString("Path")
    > CurrentPATH = server.mappath(CurrentURL) & "\"
    > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > Select Case True
    > Case oFSO.FileExists(CurrentPATH)
    > '''you have a file
    > Case oFSO.FolderExists(CurrentPATH)
    > '''you have a directory
    > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > Set oFolderContents = oFolder.Files
    > Case Else
    > '''you have nothing
    > End Select
    > -------------------------------------------------------
    >
    > gives an error on line 2 because i.e.
    >
    > path = /multimedia/2003/party/
    > then CurrentPATH = D:\Inetpub\multimedia\2003\party\
    >
    > but
    >
    > path = /multimedia/2003/party/image01.gif
    > then ERROR on CurrenPATH because the function server.mappath doesn't seems
    > to work on files
    >
    > To avoid this problem, I should place the CurrentPATH assignment in the

    Case
    > where my "Path" string contains a folder.
    > But I need the CurrentPath in the Case-statement...
    >
    > Do you have a suggestion where I can check on URL's (not on paths) if they
    > are a file or a directory?
    >
    >
    >
    >
    >
    > --
    >
    > ==========================================
    > Hyper A.R.T.
    > bart plessers
    > Paul Van Ostaijenlaan 4
    > 3001 Heverlee
    > BELGIUM
    > tel: +32 (16) 23.40.85
    > fax: +32 (16) 23.41.06
    > ==========================================
    >
    >
    >
    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:#...
    > > How about:
    > >
    > > CurrentPATH = Request.QUERYSTRING("MyLink")
    > > Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
    > > Select Case True
    > > Case oFSO.FileExists(CurrentPATH)
    > > '''you have a file
    > > Case oFSO.FolderExists(CurrentPATH)
    > > '''you have a directory
    > > Case Else
    > > '''you have nothing
    > > End Select
    > > '''etc.
    > >
    > > Ray at home
    > >
    > > --
    > > Will trade ASP help for SQL Server help
    > >
    > >
    > > "bart plessers" <> wrote in message
    > > news:...
    > > > Hello,
    > > >
    > > > Currently I am developping a internet "directory browser"
    > > >
    > > > My page 'default.asp' has following entries:
    > > >
    > > > CurrentPATH = Request("MyLink")
    > > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > > Set oFolderContents = oFolder.Files
    > > >
    > > >
    > > > this works fine with 'default.asp?MyPath', where "MyPath" stands for

    > i.e.
    > > > c:\temp\
    > > > but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    > > > c:\temp\file.txt
    > > >
    > > > Is there a way to determine if the link contains a file or a path? Of

    > > course
    > > > you can check for a dot (after dot, normaly it is an extension, thus a
    > > > file), but I want to have it possible also to have dots in my

    > > directories...
    > > >
    > > > Anybody?
    > > >
    > > >
    > > > tia!
    > > >
    > > > bartp
    > > >
    > > >

    > >
    > >

    >
    >
     
    Ray at, Jul 28, 2003
    #4
  5. hi ray,

    unfortunatly that isn't the problem.
    I also noticed this issue, and removed the backslash. Nothing changed.

    In fact I need a tool wether or not a relative URL (something like
    "\multimedia\party\" or "\multimedia\party\image.gif") is pointing to a
    directory of file.

    You don't know any syntax in asp that can do that job?

    tia

    bartp

    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    news:...
    > Perhaps the problem is that you're adding a \ onto the end of your path,

    so
    > you're going to wind up with something like:
    >
    > D:\Inetpub\multimedia\2003\party\image01.gif\
    >
    > Ray at home
    > --
    > Will trade ASP help for SQL Server help
    >
    >
    > "bart plessers" <> wrote in message
    > news:...
    > > Hi ray!
    > > thanx for quick reply
    > >
    > > I wasn't aware of your suggested script. Nice!
    > >
    > > However,
    > > I want to have a browser based on URL, not on directorypaths,
    > >
    > > so
    > >
    > > -------------------------------------------------------
    > > CurrentURL = Request.QueryString("Path")
    > > CurrentPATH = server.mappath(CurrentURL) & "\"
    > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > Select Case True
    > > Case oFSO.FileExists(CurrentPATH)
    > > '''you have a file
    > > Case oFSO.FolderExists(CurrentPATH)
    > > '''you have a directory
    > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > Set oFolderContents = oFolder.Files
    > > Case Else
    > > '''you have nothing
    > > End Select
    > > -------------------------------------------------------
    > >
    > > gives an error on line 2 because i.e.
    > >
    > > path = /multimedia/2003/party/
    > > then CurrentPATH = D:\Inetpub\multimedia\2003\party\
    > >
    > > but
    > >
    > > path = /multimedia/2003/party/image01.gif
    > > then ERROR on CurrenPATH because the function server.mappath doesn't

    seems
    > > to work on files
    > >
    > > To avoid this problem, I should place the CurrentPATH assignment in the

    > Case
    > > where my "Path" string contains a folder.
    > > But I need the CurrentPath in the Case-statement...
    > >
    > > Do you have a suggestion where I can check on URL's (not on paths) if

    they
    > > are a file or a directory?
    > >
    > >
    > >
    > >
    > >
    > > --
    > >
    > > ==========================================
    > > Hyper A.R.T.
    > > bart plessers
    > > Paul Van Ostaijenlaan 4
    > > 3001 Heverlee
    > > BELGIUM
    > > tel: +32 (16) 23.40.85
    > > fax: +32 (16) 23.41.06
    > > ==========================================
    > >
    > >
    > >
    > >
    > >
    > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > > news:#...
    > > > How about:
    > > >
    > > > CurrentPATH = Request.QUERYSTRING("MyLink")
    > > > Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
    > > > Select Case True
    > > > Case oFSO.FileExists(CurrentPATH)
    > > > '''you have a file
    > > > Case oFSO.FolderExists(CurrentPATH)
    > > > '''you have a directory
    > > > Case Else
    > > > '''you have nothing
    > > > End Select
    > > > '''etc.
    > > >
    > > > Ray at home
    > > >
    > > > --
    > > > Will trade ASP help for SQL Server help
    > > >
    > > >
    > > > "bart plessers" <> wrote in message
    > > > news:...
    > > > > Hello,
    > > > >
    > > > > Currently I am developping a internet "directory browser"
    > > > >
    > > > > My page 'default.asp' has following entries:
    > > > >
    > > > > CurrentPATH = Request("MyLink")
    > > > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > > > Set oFolderContents = oFolder.Files
    > > > >
    > > > >
    > > > > this works fine with 'default.asp?MyPath', where "MyPath" stands for

    > > i.e.
    > > > > c:\temp\
    > > > > but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    > > > > c:\temp\file.txt
    > > > >
    > > > > Is there a way to determine if the link contains a file or a path?

    Of
    > > > course
    > > > > you can check for a dot (after dot, normaly it is an extension, thus

    a
    > > > > file), but I want to have it possible also to have dots in my
    > > > directories...
    > > > >
    > > > > Anybody?
    > > > >
    > > > >
    > > > > tia!
    > > > >
    > > > > bartp
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    bart plessers, Jul 28, 2003
    #5
  6. oops. sorry. to quick, you were right!

    many thanx for your time and sorry for my arrogance

    bartp



    --

    ==========================================
    Hyper A.R.T.
    bart plessers
    Paul Van Ostaijenlaan 4
    3001 Heverlee
    BELGIUM
    tel: +32 (16) 23.40.85
    fax: +32 (16) 23.41.06
    ==========================================





    "bart plessers" <> wrote in message
    news:...
    > hi ray,
    >
    > unfortunatly that isn't the problem.
    > I also noticed this issue, and removed the backslash. Nothing changed.
    >
    > In fact I need a tool wether or not a relative URL (something like
    > "\multimedia\party\" or "\multimedia\party\image.gif") is pointing to a
    > directory of file.
    >
    > You don't know any syntax in asp that can do that job?
    >
    > tia
    >
    > bartp
    >
    > --
    >
    > ==========================================
    > Hyper A.R.T.
    > bart plessers
    > Paul Van Ostaijenlaan 4
    > 3001 Heverlee
    > BELGIUM
    > tel: +32 (16) 23.40.85
    > fax: +32 (16) 23.41.06
    > ==========================================
    >
    >
    >
    >
    >
    > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in message
    > news:...
    > > Perhaps the problem is that you're adding a \ onto the end of your path,

    > so
    > > you're going to wind up with something like:
    > >
    > > D:\Inetpub\multimedia\2003\party\image01.gif\
    > >
    > > Ray at home
    > > --
    > > Will trade ASP help for SQL Server help
    > >
    > >
    > > "bart plessers" <> wrote in message
    > > news:...
    > > > Hi ray!
    > > > thanx for quick reply
    > > >
    > > > I wasn't aware of your suggested script. Nice!
    > > >
    > > > However,
    > > > I want to have a browser based on URL, not on directorypaths,
    > > >
    > > > so
    > > >
    > > > -------------------------------------------------------
    > > > CurrentURL = Request.QueryString("Path")
    > > > CurrentPATH = server.mappath(CurrentURL) & "\"
    > > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > > Select Case True
    > > > Case oFSO.FileExists(CurrentPATH)
    > > > '''you have a file
    > > > Case oFSO.FolderExists(CurrentPATH)
    > > > '''you have a directory
    > > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > > Set oFolderContents = oFolder.Files
    > > > Case Else
    > > > '''you have nothing
    > > > End Select
    > > > -------------------------------------------------------
    > > >
    > > > gives an error on line 2 because i.e.
    > > >
    > > > path = /multimedia/2003/party/
    > > > then CurrentPATH = D:\Inetpub\multimedia\2003\party\
    > > >
    > > > but
    > > >
    > > > path = /multimedia/2003/party/image01.gif
    > > > then ERROR on CurrenPATH because the function server.mappath doesn't

    > seems
    > > > to work on files
    > > >
    > > > To avoid this problem, I should place the CurrentPATH assignment in

    the
    > > Case
    > > > where my "Path" string contains a folder.
    > > > But I need the CurrentPath in the Case-statement...
    > > >
    > > > Do you have a suggestion where I can check on URL's (not on paths) if

    > they
    > > > are a file or a directory?
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > --
    > > >
    > > > ==========================================
    > > > Hyper A.R.T.
    > > > bart plessers
    > > > Paul Van Ostaijenlaan 4
    > > > 3001 Heverlee
    > > > BELGIUM
    > > > tel: +32 (16) 23.40.85
    > > > fax: +32 (16) 23.41.06
    > > > ==========================================
    > > >
    > > >
    > > >
    > > >
    > > >
    > > > "Ray at <%=sLocation%>" <myfirstname at lane34 dot com> wrote in

    message
    > > > news:#...
    > > > > How about:
    > > > >
    > > > > CurrentPATH = Request.QUERYSTRING("MyLink")
    > > > > Set oFSO = Server.CreateObject("Scripting.FileSystemObject")
    > > > > Select Case True
    > > > > Case oFSO.FileExists(CurrentPATH)
    > > > > '''you have a file
    > > > > Case oFSO.FolderExists(CurrentPATH)
    > > > > '''you have a directory
    > > > > Case Else
    > > > > '''you have nothing
    > > > > End Select
    > > > > '''etc.
    > > > >
    > > > > Ray at home
    > > > >
    > > > > --
    > > > > Will trade ASP help for SQL Server help
    > > > >
    > > > >
    > > > > "bart plessers" <> wrote in message
    > > > > news:...
    > > > > > Hello,
    > > > > >
    > > > > > Currently I am developping a internet "directory browser"
    > > > > >
    > > > > > My page 'default.asp' has following entries:
    > > > > >
    > > > > > CurrentPATH = Request("MyLink")
    > > > > > Set oFSO = CreateObject("Scripting.FileSystemObject")
    > > > > > Set oFolder = oFSO.GetFolder(CurrentPATH)
    > > > > > Set oFolderContents = oFolder.Files
    > > > > >
    > > > > >
    > > > > > this works fine with 'default.asp?MyPath', where "MyPath" stands

    for
    > > > i.e.
    > > > > > c:\temp\
    > > > > > but NOT with 'default.asp?MyFile', where MyFile stands for i.e.
    > > > > > c:\temp\file.txt
    > > > > >
    > > > > > Is there a way to determine if the link contains a file or a path?

    > Of
    > > > > course
    > > > > > you can check for a dot (after dot, normaly it is an extension,

    thus
    > a
    > > > > > file), but I want to have it possible also to have dots in my
    > > > > directories...
    > > > > >
    > > > > > Anybody?
    > > > > >
    > > > > >
    > > > > > tia!
    > > > > >
    > > > > > bartp
    > > > > >
    > > > > >
    > > > >
    > > > >
    > > >
    > > >

    > >
    > >

    >
    >
     
    bart plessers, Jul 28, 2003
    #6
    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. Kevin Spencer

    Re: Link Link Link DANGER WILL ROBINSON!!!

    Kevin Spencer, May 17, 2005, in forum: ASP .Net
    Replies:
    0
    Views:
    864
    Kevin Spencer
    May 17, 2005
  2. topramen
    Replies:
    1
    Views:
    108
    Anthony Jones
    Feb 1, 2007
  3. Peña, Botp
    Replies:
    1
    Views:
    242
    Robert Klemme
    Jan 24, 2004
  4. Replies:
    0
    Views:
    99
  5. yusuf

    how to determine a click on a link

    yusuf, Jun 30, 2006, in forum: Javascript
    Replies:
    3
    Views:
    100
    Hal Rosser
    Jul 1, 2006
Loading...

Share This Page