Solved

ftp component again!

Posted on 2002-04-17
13
169 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 70

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
Gigs: Get Your Project Delivered by an Expert

Select from freelancers specializing in everything from database administration to programming, who have proven themselves as experts in their field. Hire the best, collaborate easily, pay securely and get projects done right.

 

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 70

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

Live: Real-Time Solutions, Start Here

Receive instant 1:1 support from technology experts, using our real-time conversation and whiteboard interface. Your first 5 minutes are always free.

Question has a verified solution.

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

Enums (shorthand for ‘enumerations’) are not often used by programmers but they can be quite valuable when they are.  What are they? An Enum is just a type of variable like a string or an Integer, but in this case one that you create that contains…
This article describes some techniques which will make your VBA or Visual Basic Classic code easier to understand and maintain, whether by you, your replacement, or another Experts-Exchange expert.
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…

816 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

10 Experts available now in Live!

Get 1:1 Help Now