Convert Long Path to Short 
Author Message
 Convert Long Path to Short

Is there an easy way to convert a long path name to the 8.3 version? For
example I want to copy the file from "C:\myfile.txt" to "C:\my files\temp
files\order processing" How would I convert the destination long path to the
short name? Any sample code would be appreciated.

Thanks,
Lando



Sun, 14 Aug 2005 23:42:23 GMT  
 Convert Long Path to Short

There is only one problem with the function below.  The file must already exist
as strLongPath in order for it to work :P

MsgBox ShortPath("C:\Program Files\Temp Files\Order Processing\MyFile.txt")

Function ShortPath(ByVal strLongPath)

  Dim objFs

  Dim objFile

  '

  ' Create the Scripting.FileSystemObject object.

  '

  Set objFs = CreateObject("Scripting.FileSystemObject")

  '

  ' Open the file.

  '

  Set objFile = objFs.GetFile(strLongPath)

  '

  ' Retrieve and return the short path.

  '

  ShortPath = objFile.shortName()

  '

  ' Destroy the file system objects.

  '

  Set objFile = Nothing

  Set objFs   = Nothing

End Function

Mythran



Mon, 15 Aug 2005 00:39:29 GMT  
 Convert Long Path to Short
Wrap a custom DLL around the relevant windows API functions is one way (and possibly the only way from script?).

http://www.vbcodemagician.dk/tips/files_shortname.htm

Chris Barber.

Is there an easy way to convert a long path name to the 8.3 version? For
example I want to copy the file from "C:\myfile.txt" to "C:\my files\temp
files\order processing" How would I convert the destination long path to the
short name? Any sample code would be appreciated.

Thanks,
Lando



Mon, 15 Aug 2005 00:44:32 GMT  
 Convert Long Path to Short

Ooh - I got beaten to it with a solution that I never expected!

Damn - and there goes my bet that it was only possible through a custom DLL - I suppose the FSO could be construed as such a thing?

Regards,

Chris.

  There is only one problem with the function below.  The file must already exist as strLongPath in order for it to work :P

  MsgBox ShortPath("C:\Program Files\Temp Files\Order Processing\MyFile.txt")

  Function ShortPath(ByVal strLongPath)

    Dim objFs

    Dim objFile

    '

    ' Create the Scripting.FileSystemObject object.

    '

    Set objFs = CreateObject("Scripting.FileSystemObject")

    '

    ' Open the file.

    '

    Set objFile = objFs.GetFile(strLongPath)

    '

    ' Retrieve and return the short path.

    '

    ShortPath = objFile.shortName()

    '

    ' Destroy the file system objects.

    '

    Set objFile = Nothing

    Set objFs   = Nothing

  End Function

  Mythran



Mon, 15 Aug 2005 03:42:27 GMT  
 Convert Long Path to Short

lol

Nice...



  Ooh - I got beaten to it with a solution that I never expected!

  Damn - and there goes my bet that it was only possible through a custom DLL - I
suppose the FSO could be construed as such a thing?

  Regards,

  Chris.


    There is only one problem with the function below.  The file must already
exist as strLongPath in order for it to work :P

    MsgBox ShortPath("C:\Program Files\Temp Files\Order Processing\MyFile.txt")

    Function ShortPath(ByVal strLongPath)

      Dim objFs

      Dim objFile

      '

      ' Create the Scripting.FileSystemObject object.

      '

      Set objFs = CreateObject("Scripting.FileSystemObject")

      '

      ' Open the file.

      '

      Set objFile = objFs.GetFile(strLongPath)

      '

      ' Retrieve and return the short path.

      '

      ShortPath = objFile.shortName()

      '

      ' Destroy the file system objects.

      '

      Set objFile = Nothing

      Set objFs   = Nothing

    End Function

    Mythran



Mon, 15 Aug 2005 05:44:41 GMT  
 
 [ 5 post ] 

 Relevant Pages 

1. Converting Paths having short name to long versions

2. converting long filename paths to short

3. Converting a Long FIleName to it's short equivalent (Both possible shorts)

4. Changing Long Paths to Short Paths in a 16-bit App

5. registry %1 argument and short/long path names

6. Converting Long File Names to Short File Names

7. Converting Long File Names to Short File Names

8. Converting Short File Names to Long File Names

9. Change long path name to short pathname

10. The long and short of it - app.path that is

11. Short -> Long file path

12. Getting Short Path Names from Long

 

 
Powered by phpBB® Forum Software