473,395 Members | 2,010 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

vb.net convert filenames to 8.3 format

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)
Nov 20 '05 #1
3 7378
* "Thom" <la*****@charter.net> scripsit:
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'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #2
Or you can use the FSO object which has a ShortName and ShortPath property for the File object.

Rgds,
Anand M
..NET MVP
http://www.dotnetindia.com

"Herfried K. Wagner [MVP]" wrote:
* "Thom" <la*****@charter.net> scripsit:
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'.

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>

Nov 20 '05 #3
* "=?Utf-8?B?QW5hbmRbTVZQfQ==?=" <An******@discussions.microsoft.com> scripsit:
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 ;-).

--
Herfried K. Wagner [MVP]
<URL:http://dotnet.mvps.org/>
Nov 20 '05 #4

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

4
by: Richard Hollenbeck | last post by:
I'm trying to write some code that will convert any of the most popular standard date formats twice in to something like "dd Mmm yyyy" (i.e. 08 Jan 1908) and compare the first with the second and...
4
by: aevans1108 | last post by:
expanding this message to microsoft.public.dotnet.xml Greetings Please direct me to the right group if this is an inappropriate place to post this question. Thanks. I want to format a...
2
by: BikeToWork | last post by:
I found code online which uses Windows API's to save Access reports to pdf format files. I'm using the full version of Adobe Acrobat Professional 7.0. The problem is that regardless of what I put...
2
by: rbutch | last post by:
guys, i need a little help with this. this is working (well sort of) i get the info, but it's not moving to a new line as it iterates thru the array and all of the fields are like ONE HUGE LONG...
1
by: abcabcabc | last post by:
I write an application which can let user define own date format to input, How to convert the date string to date value with end-user defined date format? Example, User Defined Date Format as...
2
by: Anders K. Olsen | last post by:
Hello Group I have a fileserver with several files. Some of the filenames contain danish characters (e.g. 'æ', 'ø', 'å'). Now I'm trying to make a web application in C# that presents links to...
0
by: n33470 | last post by:
We have a web site that is being converted from the 1.1 format into 2.0. I've noticed that after the web project has been converted, the first time that the solution is opened in VS, all of the...
6
by: kimiraikkonen | last post by:
Hello, I have a listbox and folder browser control. I need to display all .mp3 files' pathes into listbox. It was Ok with openfiledialog but how can list all .mp3 extension- having files into...
5
by: sonu | last post by:
hey good morning ...... how to convert a video file in .flv format in php for linux hosting......is there any package whis provide this facility . Can i use ffmpeg for linux hosting...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.