in vb6 werkt het maar krijg het nie in vb 2005 ik krijg wel de file attributes maar geen naam
Code:
Private Declare Function GetTempPath Lib "kernel32" Alias "GetTempPathA" (ByVal nBufferLength As Integer, ByVal lpBuffer As String) As Integer
Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, ByRef lpFindFileData As WIN32_FIND_DATA) As Integer
Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Integer, ByRef lpFindFileData As WIN32_FIND_DATA) As Integer
Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Integer
Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Integer) As Integer
Private Structure FILETIME
Dim dwLowDateTime As Long
Dim dwHighDateTime As Long
End Structure
Private Structure WIN32_FIND_DATA
Dim dwFileAttributes As Integer
Dim ftCreationTime As FILETIME
Dim ftLastAccessTime As FILETIME
Dim ftLastWriteTime As FILETIME
Dim nFileSizeHigh As Integer
Dim nFileSizeLow As Integer
Dim dwReserved0 As Integer
Dim dwReserved1 As Integer
<VBFixedString(MAX_PATH), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=MAX_PATH)> Dim cFileName As String
<VBFixedString(14), System.Runtime.InteropServices.MarshalAs(System.Runtime.InteropServices.UnmanagedType.ByValTStr, SizeConst:=14)> Dim cAlternate As String
End Structure
Private Const MAX_PATH As Short = 260
Private Const INVALID_HANDLE_VALUE As Short = -1
Private Const FILE_ATTRIBUTE_ARCHIVE As Short = &H20
Private Const FILE_ATTRIBUTE_DIRECTORY As Short = &H10
Private Const FILE_ATTRIBUTE_HIDDEN As Short = &H2
Private Const FILE_ATTRIBUTE_NORMAL As Short = &H80
Private Const FILE_ATTRIBUTE_READONLY As Short = &H1
Private Const FILE_ATTRIBUTE_SYSTEM As Short = &H4
Private Const FILE_ATTRIBUTE_TEMPORARY As Short = &H100
Public Shared Function GetFiles() As String
Dim FileName As String
Dim i As Integer
Dim hSearch As Integer
Dim WFD As WIN32_FIND_DATA
WFD.cFileName = New String(ch4r(0), MAX_PATH)
WFD.cAlternate = New String(ch4r(0), 14)
Dim cont As Integer
hSearch = FindFirstFile("c:\" & "*.", WFD)
cont = 1
While cont >= 1
If WFD.dwFileAttributes <> FILE_ATTRIBUTE_DIRECTORY Then
FileName = Left(WFD.cFileName.ToString, WFD.cFileName.Length)
FrmMain.RtxtPromt.Text = FrmMain.RtxtPromt.Text & FileName & vbCrLf
End If
cont = FindNextFile(hSearch, WFD)
End While
End Function