Solved

ftp component again!

Posted on 2002-04-17
13
168 Views
Last Modified: 2010-05-02
I got some great info with my last question about ftp components, now I need some more help. This is my first time using wininet.dll so I'm a little unfamiliar.
I am able to run all the functions FindFirstFile and DeleteFile etc.

What I really need to know is how to distinguish between a file and a directory.

I am creating a web based component so I cannot use any components like a list box.

I simply need some way to find out weather I have gotten a file or a directory.

As it is now when I iterate through my root directory I get files and directories printing to the page as if they were the same thing.

Help Please.
Blackpool
0
Comment
Question by:blackpool1999
  • 4
  • 3
  • 3
  • +2
13 Comments
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6949427
have a look at this free component with source: http://www.freevbcode.com/ShowCode.Asp?ID=1593
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6949490
Assuming you are talking about the files and directories on the FTP site than check out the dwFileAttributes.  These are the values I have used

Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Const FILE_ATTRIBUTE_COMPRESSED = &H800
Private Const FILE_ATTRIBUTE_OFFLINE = &H1000

Anthony
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6949532
black, you could modify my EnumFTPFiles to get ALL details of files founded!
http://www.experts-exchange.com/jsp/qShow.jsp?ta=visualbasic&qid=20288523
0
 

Author Comment

by:blackpool1999
ID: 6949694
emoreau- I have looked at that component and cannot see how it is done.

Anthony- I'm not sure how to use what you have given me.
I am not sure how to set up my Do loop usinf FindNextFile to check for directory or not.

Richie- I have attempted to modify your function with no success. It is not clear to me how to get the files info. I have tried to get pData.dwFileAttributes at the same time as pData.cFileName but I get nothing on return.
0
 
LVL 69

Expert Comment

by:Éric Moreau
ID: 6950083
run the sample and you will see the listview filled with different icons depending of their folder/file attributes.
0
 
LVL 2

Expert Comment

by:damion69
ID: 6950672
0
Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

 
LVL 16

Accepted Solution

by:
Richie_Simonetti earned 100 total points
ID: 6950692
just try this:

If (pData.dwFileAttributes And vbDirectory) = vbDirectory Then
        Debug.Print pData.cFileName & ": Folder"
    ElseIf (pData.dwFileAttributes And vbArchive) = vbArchive Then
        Debug.Print pData.cFileName & ": Archive"
    End If
0
 

Author Comment

by:blackpool1999
ID: 6952216
Richie I see what your talking about, but dwFileAttributes is a Long integer, and I am not sure what vbDirectory and vbArchive are?
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6952245
It does not matter whether it is a Long or Integer.
If you are not sure what the value of a VB constant you can always check in the immediate window or look it up in the help. From the immediate window do:
? vbDirectory, vbArchive

In this case the result is:
 16         32

Which coincidently is the same as I posted originally:
Private Const FILE_ATTRIBUTE_READONLY = &H1
Private Const FILE_ATTRIBUTE_HIDDEN = &H2
Private Const FILE_ATTRIBUTE_SYSTEM = &H4
Private Const FILE_ATTRIBUTE_DIRECTORY = &H10
Private Const FILE_ATTRIBUTE_ARCHIVE = &H20
Private Const FILE_ATTRIBUTE_NORMAL = &H80
Private Const FILE_ATTRIBUTE_TEMPORARY = &H100
Private Const FILE_ATTRIBUTE_COMPRESSED = &H800
Private Const FILE_ATTRIBUTE_OFFLINE = &H1000

Anthony
0
 
LVL 75

Expert Comment

by:Anthony Perkins
ID: 6952251
The line:
Which coincidently is the same as I posted originally:
should have read:
Which coincidently is the same as I posted originally: <smile>

Anthony
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6952502
As Tony saids, there is no problem is long or integer.
vbarchive and vbdirectory are contants that you can see in object browser in IDE.
vbDirectory =16
vbArchive=32
both values meets in an integer as in a long type variable.
I don't use contstants since those values are already availables as vbfileatribute constants.
Cheers
0
 

Author Comment

by:blackpool1999
ID: 6955272
Thanks a lot. Sorry I was a little slow on the uptake, function works great.

Blackpool
0
 
LVL 16

Expert Comment

by:Richie_Simonetti
ID: 6955471
Thanks for "A" grade...again.
If you need more details regarding that piece of code just ask here if you like.
Cheers
0

Featured Post

Is Your Active Directory as Secure as You Think?

More than 75% of all records are compromised because of the loss or theft of a privileged credential. Experts have been exploring Active Directory infrastructure to identify key threats and establish best practices for keeping data safe. Attend this month’s webinar to learn more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Suggested Solutions

You can of course define an array to hold data that is of a particular type like an array of Strings to hold customer names or an array of Doubles to hold customer sales, but what do you do if you want to coordinate that data? This article describes…
Since upgrading to Office 2013 or higher installing the Smart Indenter addin will fail. This article will explain how to install it so it will work regardless of the Office version installed.
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Show developers how to use a criteria form to limit the data that appears on an Access report. It is a common requirement that users can specify the criteria for a report at runtime. The easiest way to accomplish this is using a criteria form that a…

867 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

15 Experts available now in Live!

Get 1:1 Help Now