Solved

ftp component again!

Posted on 2002-04-17
13
167 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
Why You Should Analyze Threat Actor TTPs

After years of analyzing threat actor behavior, it’s become clear that at any given time there are specific tactics, techniques, and procedures (TTPs) that are particularly prevalent. By analyzing and understanding these TTPs, you can dramatically enhance your security program.

 
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

Highfive Gives IT Their Time Back

Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

Join & Write a Comment

Have you ever wanted to restrict the users input in a textbox to numbers, and while doing that make sure that they can't 'cheat' by pasting in non-numeric text? Of course you can do that with code you write yourself but it's tedious and error-prone …
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.
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…
This lesson covers basic error handling code in Microsoft Excel using VBA. This is the first lesson in a 3-part series that uses code to loop through an Excel spreadsheet in VBA and then fix errors, taking advantage of error handling code. This l…

746 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

11 Experts available now in Live!

Get 1:1 Help Now