Results 1 to 4 of 4

Thread: Aliasing Long Paths to Short Paths

  1. #1

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622

    Aliasing Long Paths to Short Paths

    I need to convert a long file name eg. "c:\This is a long\Path that needs to be converted to\an 8.3 format\my file.txt"

    It would look something like this:

    "c:\thisis~1\Pathth~1\needst~1\an83fo~1\myfile.txt"


    I am aware of "GetShortPath" API call but it does not fit my purposes.

    Is there any existing solution, or must i create my own?
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  2. #2
    I'm about to be a PowerPoster! mendhak's Avatar
    Join Date
    Feb 2002
    Location
    Ulaan Baator GooGoo: Frog
    Posts
    38,170
    What does the GetShortPath API lack that makes it unfit for you?

  3. #3

    Thread Starter
    Frenzied Member <ABX's Avatar
    Join Date
    Jul 2002
    Location
    Canada eh...
    Posts
    1,622
    It doesnt work for files that dont exist.

    I am using M$ unsupported LogParser.dll to Export some IIS logs to XML and display them on a website, this works fine unless you use a path that has a space in it because the engine assumes the file name ends when there is a space. I need to provide both the input and the output paths in MSDOS 8.3 Format.
    Tips:
    • Google is your friend! Search before posting!
    • Name your thread appropriately... "I Need Help" doesn't cut it!
    • Always post your code!!!! We can't read your mind!!! (well, at least most of us!)
    • Allways Include the Name and Line of the Exception (if one is occuring!)
    • If it is relevant state the version of Visual Studio/.Net Framwork you are using (2002/2003/2005)


    If you think I was helpful, rate my post
    IRC Contact: Rizon/xous ChakraNET/xous Freenode/xous

  4. #4
    type Woss is new Grumpy; wossname's Avatar
    Join Date
    Aug 2002
    Location
    #!/bin/bash
    Posts
    5,682
    Hmm, an interesting question.

    One problem is that if you have 2 similar directories like

    C:\Venerable Bede's files\
    C:\Venerable Bede's stuff\

    You will get

    C:\Venera~1\
    C:\Venera~2\

    So you have to check for that.

    Assuming that your folder is pretty unique, you can do the following>

    1. take the long path and use string.split() to chop it up using "\" as the delimiter.

    2. for each foldername in the new array remove all spaces from the name and then discard everything after the first 6 characters. (You will have to treat the drive letter and file extension separately)

    3. append "~1" to the end of each foldername (where appropriate).

    4. string.join() them back together again and you should have something resembling what you want.

    This is just of the top of my head of course, it might be a bit more complicated than that.

    I'll look into it.
    I don't live here any more.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width