how to get 8.3 format filename from long filename

Discussion in 'Java' started by jacobyv@sis.unibe.ch, Jun 15, 2006.

  1. Guest

    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
     
    , Jun 15, 2006
    #1
    1. Advertising

  2. wrote:
    > 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\"");
    --
    Regards,

    Roland
     
    Roland de Ruiter, Jun 15, 2006
    #2
    1. Advertising

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

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Anthony Lansbergen

    long filename problem with new include format

    Anthony Lansbergen, Jun 7, 2004, in forum: C++
    Replies:
    4
    Views:
    442
    Richard Herring
    Jun 8, 2004
  2. George Marsaglia

    Assigning unsigned long to unsigned long long

    George Marsaglia, Jul 8, 2003, in forum: C Programming
    Replies:
    1
    Views:
    746
    Eric Sosman
    Jul 8, 2003
  3. robert
    Replies:
    1
    Views:
    4,374
    Dennis Lee Bieber
    Jul 1, 2006
  4. Daniel Rudy

    unsigned long long int to long double

    Daniel Rudy, Sep 19, 2005, in forum: C Programming
    Replies:
    5
    Views:
    1,244
    Peter Shaggy Haywood
    Sep 20, 2005
  5. Mathieu Dutour

    long long and long

    Mathieu Dutour, Jul 17, 2007, in forum: C Programming
    Replies:
    4
    Views:
    515
    santosh
    Jul 24, 2007
Loading...

Share This Page