[AccessD] File Created with wrong name

Gustav Brock Gustav at cactus.dk
Fri Jan 13 09:46:11 CST 2006


Hi Reuben

It's the short filename.

You may convert to and from the short and long filename:

<code>

' -------------------------------------------------------------------------
' Declarations for GetShortFileName.

Private Declare Function GetLongPathName Lib "kernel32" Alias "GetLongPathNameA" ( _
  ByVal lpszShortPath As String, _
  ByVal lpszLongPath As String, _
  ByVal cchBuffer As Long) As Long

Private Declare Function GetShortPathName Lib "kernel32" Alias "GetShortPathNameA" ( _
  ByVal lpszLongPath As String, _
  ByVal lpszShortPath As String, _
  ByVal cchBuffer As Long) As Long


Public Function GetShortFileName(ByVal FullPath As String) As String

'PURPOSE: Returns DOS File Name (8.3 Format) Give
'FullPath for long file name

'PARAMETERS: FullPath: Full Path of Original File

'RETURNS: 8.3 FileName, or "" if FullPath doesn't
'         exist or file fails for other reasons

'EXAMPLE:
'Debug.Print _
'  GetShortFileName("C:\My Documents\My Very Long File Name.doc")

'If file exists, will display C:\MYDOCU~1\MYVERY~1.DOC
'in the debug window

Dim lAns As Long
Dim sAns As String
Dim iLen As Integer
   
On Error Resume Next

'this function doesn't work if the file doesn't exist
'''If Dir(FullPath) = "" Then Exit Function

sAns = Space(255)
lAns = GetShortPathName(FullPath, sAns, 255)
GetShortFileName = Left(sAns, lAns)
    
End Function

Public Function GetLongFileName(ByVal FullPath As String) As String

'PURPOSE:
' Returns FullPath for short file name (8.3 Format)
' Give long File Name

'PARAMETERS: FullPath: Full Path of Original File

'RETURNS: FileName, or "" if FullPath doesn't
'         exist or file fails for other reasons

'EXAMPLE:
'Debug.Print _
'  GetShortFileName("C:\My Documents\My Very Long File Name.doc")

'If file exists, will display C:\MYDOCU~1\MYVERY~1.DOC
'in the debug window

Dim lAns As Long
Dim sAns As String
Dim iLen As Integer
   
On Error Resume Next

'this function doesn't work if the file doesn't exist
'''If Dir(FullPath) = "" Then Exit Function

sAns = Space(255)
lAns = GetLongPathName(FullPath, sAns, 255)
GetLongFileName = Left(sAns, lAns)
    
End Function

</code>

/gustav


>>> reuben at gfconsultants.com 13-01-2006 16:25 >>>
I have a feature that allows a user to zip the data file or zip it and FTP
it to my web server.

It has worked flawlessly until now...the reason is that the file name that
the zip file got saved to was not what it's supposed to be.  I need help
figuring out why the file name was incorrect.

The data file (in this case) is named   chrttable.mdb

I append some data from the app to create a unique file name.  The name ends
up being   chrttableAllenCounty01132006.zip

The client's system produced a zip file named     chrtta~1.zip

Why is the name trucnated and changed to chrtta~1.zip?

Thanks.

Reuben Cummings
GFC, LLC
812.523.1017





More information about the AccessD mailing list