Hi
I have the following code in a module:
If i have a text file in C:Code:Option Explicit Private Const OF_EXIST As Long = &H4000 Private Const OFS_MAXPATHNAME As Long = 128 Private Const HFILE_ERROR As Long = -1 Private Type OFSTRUCT cBytes As Byte fFixedDisk As Byte nErrCode As Integer Reserved1 As Integer Reserved2 As Integer szPathName(OFS_MAXPATHNAME) As Byte End Type Private Declare Function OpenFile Lib "kernel32" (ByVal lpFileName As String, lpReOpenBuff As OFSTRUCT, ByVal wStyle As Long) As Long Public Function FileExists(ByVal Fname As String) As Boolean Dim lRetVal As Long Dim OfSt As OFSTRUCT lRetVal = OpenFile(Fname, OfSt, OF_EXIST) If lRetVal <> HFILE_ERROR Then FileExists = True Else FileExists = False End If End Function
"C:\111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111.txt"
Then running FileExists("C:\1111111111111111111111111111111111111111111111111111111111111111111111111111111111111 1111111111111111111111111111111111.txt") will return true.
If i add another "1" to that filename i.e make it become:
"C:\111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111111 111111111111111111111111.txt"
Then FileExists("C:\1111111111111111111111111111111111111111111111111111111111111111111111111111111111111 11111111111111111111111111111111111.txt") returns false although the file exists.
As long as the length of the filename is less or equal 126 the function works fine. If it's greater than 126 it will always return false
Any one has a solution to this?
Thanks,
Krishley





Reply With Quote