how to get 8.3 format filename from long filename

J

jacobyv

hi

i've seen a few posts to this problem but didn't find a solution.

i want to open a document. it works fine if the path ist 8.3 format
compatible.

however, the example below does not work.

Runtime.getRuntime().exec("cmd.exe /c start c:\\temp\\long
filename.csv");


if i use the 8.3 dos format path it works.
Runtime.getRuntime().exec("cmd.exe /c start c:\\temp\\LONGFI~1.CSV");

how do i get the 8.3 format path in JAVA?
or is there another solution to open the file, without using the 8.3
format.

thanks a lot for your support.

greetings
yves
 
R

Roland de Ruiter

hi

i've seen a few posts to this problem but didn't find a solution.

i want to open a document. it works fine if the path ist 8.3 format
compatible.

however, the example below does not work.

Runtime.getRuntime().exec("cmd.exe /c start c:\\temp\\long
filename.csv");


if i use the 8.3 dos format path it works.
Runtime.getRuntime().exec("cmd.exe /c start c:\\temp\\LONGFI~1.CSV");

how do i get the 8.3 format path in JAVA?
or is there another solution to open the file, without using the 8.3
format.

thanks a lot for your support.

greetings
yves
Enclose the long filename in quotes. However, when the start command
sees a parameter with qoutes, it takes it as the title of the command
window (at least on WinXP). So you have to specify a (dummy) window
title as well:
....exec("cmd.exe /c start \"winttl\" \"c:\\temp\\long filename.csv\"");
 

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

Members online

Forum statistics

Threads
473,756
Messages
2,569,533
Members
45,007
Latest member
OrderFitnessKetoCapsules

Latest Threads

Top