djdidge
asked on
FTP ... check if dir exists
how can I check if a directory exists on an FTP svr.
And how can I get a file count of files in that dir?
Thanks
And how can I get a file count of files in that dir?
Thanks
ASKER
ftp server is on the same LAN as my web server... yes I'd like to check if the dir exists with ASP (FSO doesn't work, or atleast I can't get it to).
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
ASKER
thanks for that.... but my major issue is checking the existance of a dir on the ftp
this code will check the existence od "mydir", before proceeding
you can validate the value of variable f
you can validate the value of variable f
FolderExists Method
Returns True if a specified folder exists; False if it does not.
object.FolderExists(folder spec)
Arguments
object
Required. Always the name of a FileSystemObject.
folderspec
Required. The name of the folder whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the folder isn't expected to exist in the current folder.
Remarks
The following example illustrates use of the FolderExists method:
Function ReportFolderStatus(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
If (fso.FolderExists(fldr)) Then
msg = fldr & " exists."
Else
msg = fldr & " doesn't exist."
End If
ReportFolderStatus = msg
End Function
Files Collection
Collection of all File objects within a folder.
Remarks
The following code illustrates how to get a Files collection and iterate the collection using the For Each...Next statement:
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFolderList = s
End Function
Returns True if a specified folder exists; False if it does not.
object.FolderExists(folder
Arguments
object
Required. Always the name of a FileSystemObject.
folderspec
Required. The name of the folder whose existence is to be determined. A complete path specification (either absolute or relative) must be provided if the folder isn't expected to exist in the current folder.
Remarks
The following example illustrates use of the FolderExists method:
Function ReportFolderStatus(fldr)
Dim fso, msg
Set fso = CreateObject("Scripting.Fi
If (fso.FolderExists(fldr)) Then
msg = fldr & " exists."
Else
msg = fldr & " doesn't exist."
End If
ReportFolderStatus = msg
End Function
Files Collection
Collection of all File objects within a folder.
Remarks
The following code illustrates how to get a Files collection and iterate the collection using the For Each...Next statement:
Function ShowFolderList(folderspec)
Dim fso, f, f1, fc, s
Set fso = CreateObject("Scripting.Fi
Set f = fso.GetFolder(folderspec)
Set fc = f.Files
For Each f1 in fc
s = s & f1.name
s = s & "<BR>"
Next
ShowFolderList = s
End Function
Try etiveFTP component. It provides "List" method, which returns file & directories list on remote FTP server.
Demo could be downloaded from http://www.etive.com/software/etiveftp/
Demo could be downloaded from http://www.etive.com/software/etiveftp/
ASKER
thanks all... I currently have a development rush on... as soon as that is sorted I shall evaluate your suggestions...
Thanks!!
Thanks!!
"Use the FSO Luke..."
It really doesn't get any easier than this;
<%
Dim fso, msg, fldr
fldr = "c:\inetpub\ftproot\test"
Set fso = CreateObject("Scripting.Fi leSystemOb ject")
If (fso.FolderExists(fldr)) Then
Response.Write fldr & " exists."
Else
Response.Write fldr & " doesn't exist."
End If
ReportFolderStatus = msg
%>
It really doesn't get any easier than this;
<%
Dim fso, msg, fldr
fldr = "c:\inetpub\ftproot\test"
Set fso = CreateObject("Scripting.Fi
If (fso.FolderExists(fldr)) Then
Response.Write fldr & " exists."
Else
Response.Write fldr & " doesn't exist."
End If
ReportFolderStatus = msg
%>
ASKER
I have just looked briefly at your suggestions... just to reaffirm my issue,
The FTP server that i need to check if a directory exists isn't the machine that the script is to run on...
ie question re-word:
I need to check if a directory exists on a FTP server from a client machine
....
If your suggestions fit this profile then i appologise!
Gary
The FTP server that i need to check if a directory exists isn't the machine that the script is to run on...
ie question re-word:
I need to check if a directory exists on a FTP server from a client machine
....
If your suggestions fit this profile then i appologise!
Gary
ASKER
u were first
That answer only counts files... you had a 2 part question.
do u want to check using ASP ??