• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 179
  • Last Modified:

ftp component again!

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
blackpool1999
Asked:
blackpool1999
  • 4
  • 3
  • 3
  • +2
1 Solution
 
Éric MoreauSenior .Net ConsultantCommented:
have a look at this free component with source: http://www.freevbcode.com/ShowCode.Asp?ID=1593
0
 
Anthony PerkinsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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!

 
blackpool1999Author Commented:
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
 
Éric MoreauSenior .Net ConsultantCommented:
run the sample and you will see the listview filled with different icons depending of their folder/file attributes.
0
 
damion69Commented:
0
 
Richie_SimonettiIT OperationsCommented:
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
 
blackpool1999Author Commented:
Richie I see what your talking about, but dwFileAttributes is a Long integer, and I am not sure what vbDirectory and vbArchive are?
0
 
Anthony PerkinsCommented:
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
 
Anthony PerkinsCommented:
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
 
Richie_SimonettiIT OperationsCommented:
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
 
blackpool1999Author Commented:
Thanks a lot. Sorry I was a little slow on the uptake, function works great.

Blackpool
0
 
Richie_SimonettiIT OperationsCommented:
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

Concerto Cloud for Software Providers & ISVs

Can Concerto Cloud Services help you focus on evolving your application offerings, while delivering the best cloud experience to your customers? From DevOps to revenue models and customer support, the answer is yes!

Learn how Concerto can help you.

  • 4
  • 3
  • 3
  • +2
Tackle projects and never again get stuck behind a technical roadblock.
Join Now