Solved

ftp component again!

Posted on 2002-04-17
13
173 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 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
Independent Software Vendors: We Want Your Opinion

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

 

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

Technology Partners: We Want Your Opinion!

We value your feedback.

Take our survey and automatically be enter to win anyone of the following:
Yeti Cooler, Amazon eGift Card, and Movie eGift Card!

Question has a verified solution.

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

If you have ever used Microsoft Word then you know that it has a good spell checker and it may have occurred to you that the ability to check spelling might be a nice piece of functionality to add to certain applications of yours. Well the code that…
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.
Get people started with the process of using Access VBA to control Excel using automation, Microsoft Access can control other applications. An example is the ability to programmatically talk to Excel. Using automation, an Access application can laun…
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…

729 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