我就在这里
分类: Sybase
2013-02-27 13:53:27
Constant Long MAXDWORD = 65535 //&HFFFF
Constant Long INVALID_HANDLE_VALUE = -1
Constant Long FILE_ATTRIBUTE_ARCHIVE = 32 //&H20
Constant Long FILE_ATTRIBUTE_DIRECTORY = 16 //&H10
Constant Long FILE_ATTRIBUTE_HIDDEN = 2 //&H2
Constant Long FILE_ATTRIBUTE_NORMAL = 128 //&H80
Constant Long FILE_ATTRIBUTE_READONLY = 1 //&H1
Constant Long FILE_ATTRIBUTE_SYSTEM = 4 //&H4
Constant Long FILE_ATTRIBUTE_TEMPORARY = 256 //&H100
Constant Long BIF_RETURNONLYFSDIRS = 1
定义结构:
Type FileTime From structure
Long dwLowDateTime
Long dwHighDateTime
End Type
Type WIN32_FIND_DATA From structure
Long dwFileAttributes
FileTime ftCreationTime
FileTime ftLastAccessTime
FileTime ftLastWriteTime
Long nFileSizeHigh
Long nFileSizeLow
Long dwReserved0
Long dwReserved1
Character cFileName[260]
Character cAlternate[16]
End Type
声明API:
Function ULong FindFirstFile(String lpFilePath, Ref WIN32_FIND_DATA lpFindFileData) Library "kernel32.dll" Alias For "FindFirstFileW"定义函数:
public subroutine FileList(string as_filepath, ref string as_filename[]);//as_FilePath 文件路径,as_FileName[]返回的文件列表
String ls_FileName, ls_FileAttrib, ls_FilePath
ULong hFind, hNext
WIN32_FIND_DATA WFD
ls_FilePath = as_FilePath+"\*.*"
hFind = FindFirstFile(ls_FilePath, WFD);
If hFind = INVALID_HANDLE_VALUE Then
ls_FileName = String(WFD.cFileName)
//ls_FileAttrib = String(WFD.dwFileAttributes )
as_FileName[UpperBound(as_FileName) +1] = ls_FileName
Else
Do While(hFind > 0)
hNext = FindNextFile(hFind,WFD)
If hNext > 0 Then
ls_FileName = String(WFD.cFileName)
If ls_FileName = ".." Then Continue
If WFD.dwFileAttributes = FILE_ATTRIBUTE_DIRECTORY Then
FileList(as_FilePath+"\"+ls_FileName, as_FileName[])
Else
//ls_FileAttrib = String(WFD.dwFileAttributes )
as_FileName[UpperBound(as_FileName) +1] = as_FilePath+"\"+ls_FileName
End If
Else
Exit
End If
Loop
FindClose(hFind)
End If
end subroutine
转自: