vb.net convert filenames to 8.3 format

  • Thread starter Thread starter Thom
  • Start date Start date
T

Thom

I'm trying to use shell to execute an old dos based program. This program
takes a binary file and does internal processing and then outputs a text
file based on the processing.
I am choking on the spaces in the valid pathnames.

Any ideas on how to convert from the long file name format to an 8.3 format?

Thank you for any help.
Thom

Here is the code snippet that works in a controlled environment ....ie no
spaces in the path names.

If strTextFileName1 <> "" Then 'make sure the 1st filename is not empty
Dim ProcID As Integer
'create a string to the command path
Dim runString As String
runString = "dcmdump.exe " & strBinFile1 & " > " & strTextFileName1
' Run dcmdump.
ProcID = Shell(runString, AppWinStyle.NormalFocus, True, 8000)
 
* "Thom said:
I'm trying to use shell to execute an old dos based program. This program
takes a binary file and does internal processing and then outputs a text
file based on the processing.
I am choking on the spaces in the valid pathnames.

Any ideas on how to convert from the long file name format to an 8.3 format?

Thank you for any help.
Thom

Here is the code snippet that works in a controlled environment ....ie no
spaces in the path names.

If strTextFileName1 <> "" Then 'make sure the 1st filename is not empty
Dim ProcID As Integer
'create a string to the command path
Dim runString As String
runString = "dcmdump.exe " & strBinFile1 & " > " & strTextFileName1
' Run dcmdump.
ProcID = Shell(runString, AppWinStyle.NormalFocus, True, 8000)

\\\
\\\
Private Declare Auto Function GetShortPathName Lib "kernel32.dll" ( _
ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, _
ByVal cchBuffer As Int32 _
) As Int32
..
..
..
Dim strPath As String = Application.StartupPath
Dim strShortPath As String = Space(100)
Dim n As Int32 = GetShortPathName(strPath, strShortPath, 100)
MsgBox(Strings.Left(strShortPath, n))
///

Instead of the string buffer, you can use a 'StringBuilder'.
 
* "=?Utf-8?B?QW5hbmRbTVZQfQ==?= said:
Or you can use the FSO object which has a ShortName and ShortPath
property for the File object.

Yep. But I don't like the FSO ;-).
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Back
Top