473,395 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

how to determine if link is directory or file?

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
==========================================


Jul 19 '05 #1
5 2187
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" <ba**********@hotmail.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
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

Jul 19 '05 #2
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:#y**************@TK2MSFTNGP10.phx.gbl...
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" <ba**********@hotmail.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
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


Jul 19 '05 #3
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" <ba**********@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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:#y**************@TK2MSFTNGP10.phx.gbl...
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" <ba**********@hotmail.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
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



Jul 19 '05 #4
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:O5**************@TK2MSFTNGP12.phx.gbl...
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" <ba**********@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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:#y**************@TK2MSFTNGP10.phx.gbl...
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" <ba**********@hotmail.com> wrote in message
news:uq**************@tk2msftngp13.phx.gbl...
> 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
>
>



Jul 19 '05 #5
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" <ba**********@hotmail.com> wrote in message
news:eY**************@tk2msftngp13.phx.gbl...
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:O5**************@TK2MSFTNGP12.phx.gbl...
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" <ba**********@hotmail.com> wrote in message
news:en**************@tk2msftngp13.phx.gbl...
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:#y**************@TK2MSFTNGP10.phx.gbl...
> 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" <ba**********@hotmail.com> wrote in message
> news:uq**************@tk2msftngp13.phx.gbl...
> > 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
> >
> >
>
>



Jul 19 '05 #6

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

Similar topics

4
by: Bart Plessers \(artabel\) | last post by:
Hello, I have an asp script that lists the files in a directory: CurrentPATH = "c:\temp\" Set oFSO = CreateObject("Scripting.FileSystemObject") Set oFolder = oFSO.GetFolder(CurrentPATH) Set...
4
by: HKannen | last post by:
Hi everybody, I'd like to create a link to a file instead of copying the file to the new destination. Is there a possibility to do this ? Is there something like a Link Object in C# .NET ? ...
6
by: dawn | last post by:
Hi, How can I determine the directory from which my app is started. Since upon installation the user can decide in which directory to install the file...I want to be able to load a file from a...
3
by: KSC | last post by:
Hello, Is there a way to programmatically determine if a directory is shared and if so, what the sharename is? It seems a simple question, but I have been searching and not found the...
5
by: Dino Buljubasic | last post by:
My application can allow a user to open a file for viewing by fetching file data from database, creating the file in a temp directory and starting appropriate process (i.e. Adobe or any other...
3
by: Mark Gibson | last post by:
Is there an equivalent to the unix 'file' command? $ file min.txt min.txt: ASCII text $ file trunk trunk: directory $ file compliance.tgz compliance.tgz: gzip compressed data, from Unix ...
1
by: topramen | last post by:
does any one here know of a good way to to determine whether or not a given path is a directory (e.g., "c:\mydir") or a file (e.g., "c:\mydir \myfile.txt")? i started attacking this problem by...
1
by: amygrant1701 | last post by:
Hi, I've done this before so I don't see what I could doing wrong here. I'm running mysql 5x on freebsd. I'm using the default data directory of "/var/db/mysql" In there I have several dozen...
9
by: Scott | last post by:
What is the most reliable method to determine the folder a script is running in? I was looking at the globals in $_SERVER but all the variables also listed the actual file the script was running...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

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.