![]() |
|
|
Welcome to the { mindfrost82.com } forums. You are currently viewing our boards as a guest which gives you limited access to view most discussions and access our other features. By joining our free community you will have access to post topics, communicate privately with other members (PM), respond to polls, upload content and access many other special features. Registration is fast, simple and absolutely free so please, join our community today! If you have any problems with the registration process or your account login, please contact contact us. |
|
|||||||
![]() |
|
|
LinkBack | Thread Tools | Search this Thread | Display Modes |
|
|||
|
fname = Dir("C:\Bob\*.*")
...code snippet..
fname = Dir("C:\Bob\*.*") If fname = "" Then MsgBox "There Are No Files On The SD Card.", , "": Exit Sub If fname <> "" Then.. ...............................end snippet... When running.. fname = Dir("C:\Bob\*.*") ...and there is at least one file in the Folder, sometimes fname will show "". My code includes deleting all files in that Folder after I run code to Import the .txt files into Access. Could that be causing the fname = ""..when that occurs?? Is there any other code to 100% see a fname = ""....when it is that? TIA - Bob |
|
|||
|
Re: fname = Dir("C:\Bob\*.*")
Don't rely on VBA
use: Private Declare Function FindFirstFile Lib "kernel32" Alias "FindFirstFileA" (ByVal lpFileName As String, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function FindNextFile Lib "kernel32" Alias "FindNextFileA" (ByVal hFindFile As Long, lpFindFileData As WIN32_FIND_DATA) As Long Private Declare Function GetFileAttributes Lib "kernel32" Alias "GetFileAttributesA" (ByVal lpFileName As String) As Long Private Declare Function FindClose Lib "kernel32" (ByVal hFindFile As Long) As Long Private Type WIN32_FIND_DATA dwFileAttributes As Long ftCreationTime As FILETIME ftLastAccessTime As FILETIME ftLastWriteTime As FILETIME nFileSizeHigh As Long nFileSizeLow As Long dwReserved0 As Long dwReserved1 As Long cFileName As String * MAX_PATH cAlternate As String * 14 End Type 'File Handling Private Const FILE_CURRENT = 1& Private Const FILE_BEGIN = 0& Private Const GENERIC_READ = &H80000000 Private Const GENERIC_WRITE = &H40000000 Private Const FILE_SHARE_READ = &H1 Private Const FILE_SHARE_WRITE = &H2 Private Const OPEN_EXISTING = 3& Private Const FILE_FLAG_RANDOM_ACCESS = &H10000000 Private Const FILE_ATTRIBUTE_NORMAL = &H80 Private Const FILE_ATTRIBUTE_ARCHIVE = &H20 Private Const FILE_ATTRIBUTE_DIRECTORY = &H10 Private Const FILE_ATTRIBUTE_HIDDEN = &H2 Private Const FILE_ATTRIBUTE_READONLY = &H1 Private Const FILE_ATTRIBUTE_System = &H4 Private Const FILE_ATTRIBUTE_TEMPORARY = &H100 Private Const CREATE_ALWAYS = 2& Pieter "Bob Barnes" <BobBarnes@discussions.microsoft.com> wrote in message news:A839D8F4-96DD-4C3C-8537-CD2548C39137@microsoft.com... > ..code snippet.. > fname = Dir("C:\Bob\*.*") > If fname = "" Then MsgBox "There Are No Files On The SD Card.", , "": Exit > Sub > If fname <> "" Then.. > ..............................end snippet... > > When running.. > fname = Dir("C:\Bob\*.*") > > ..and there is at least one file in the Folder, sometimes fname will show > "". > > My code includes deleting all files in that Folder after I run code to > Import the .txt files into Access. Could that be causing the fname = > ""..when that occurs?? > > Is there any other code to 100% see a fname = ""....when it is that? > > TIA - Bob > |
![]() |
|
| Thread Tools | Search this Thread |
| Display Modes | |
|
|