locked
Path length limitations? RRS feed

  • Question

  • I read online about the file\path limitation of 255 for WinXP and 260 for Vista - that includes every character used for the path and file.
    I assume these limits apply to Small Basic.  The way I want to move forward with my current project is to ask for a user name and make that name as part of the path.
    But without knowing where the executable will be placed on any computer, I am using the full path C:\[path of the .exe]\[user name]\maps\[map name].dms

    So I am starting with a deficit of at least 15 (possibility of 13 if .exe is in C:\) characters, but usually will be more.

    Is there a way to perform Change Directory (a CHDIR or CD) like you find in DOS?
    This way, if the current directory is within a subdirectory of my choosing, the "path" can start from there instead of starting all the way back to the root (C:\).

    Sunday, August 8, 2010 5:14 PM

Answers

  • I came up with a work-around.

    Instead of using the .exe file's location, use the My Documents folder to save the map projects by using %HOMEPATH%.

    WinXP: %HOMEPATH%\My Documents

    Vista:  %HOMEPATH%\Documents

    Then limit number of characters for User Name and Map Project name.

    Sunday, August 8, 2010 11:24 PM
  • Maybe i should have been more specific with the term database. For simplicity and as its a Microsoft language then access to Microsoft Access Database would be nice but troublesome when you have to introduce SQL as well or standard library XML file access would be great. You can write your own text based database but its somewhat annoying and a pain. As if you don't make it portable enough you will be re writing the underlying code for any project you want to add a Database to.
    Monday, August 9, 2010 4:06 PM
  • You could avoid that issue by doing it slightly differently. With the folder being given a completely random name (say 20 characters long or so) Then inside the folder create a text file that contains the folders details this way if you move it then you won't have that issue unless you get really unlucky with the random file name generation and then you just look in all the folders. This way merging file systems will most likely work and a corrupted main database file will not make your entire app break as there is none.
    Tuesday, August 10, 2010 10:58 AM

All replies

  • I came up with a work-around.

    Instead of using the .exe file's location, use the My Documents folder to save the map projects by using %HOMEPATH%.

    WinXP: %HOMEPATH%\My Documents

    Vista:  %HOMEPATH%\Documents

    Then limit number of characters for User Name and Map Project name.

    Sunday, August 8, 2010 11:24 PM
  • I really would be surprised if this limitation would ever be an issue. You could also limit the user name and map name or truncate them accordingly to prevent it ever occurring as you said or store the usernames and mapnames in a file and then stick them all in the same folder with each mapname given a unique name (maybe an ID). 

    Ideally SmallBasic needs basic database support but that would lead to too many complexities for a beginner language.

    Monday, August 9, 2010 12:03 PM
  • How about something like this?

    DatabaseVariable["User"]["Maps"]["1"] = "C:\[path of the .exe]\MapStore\[ID of Map].dms"

    DatabaseVariable["User"]["Maps"]["2"] = "C:\[path of the .exe]\MapStore\[ID of Map].dms"

    File.Writeline(C:\[path of the .exe]\Database.DB,1,DatabaseVariable)

    Also don't use long folder names.

    And Tubbz , what you mean with Database? I think we can use primitive as database.
    Sorry My Bad English
    Monday, August 9, 2010 12:53 PM
  • Maybe i should have been more specific with the term database. For simplicity and as its a Microsoft language then access to Microsoft Access Database would be nice but troublesome when you have to introduce SQL as well or standard library XML file access would be great. You can write your own text based database but its somewhat annoying and a pain. As if you don't make it portable enough you will be re writing the underlying code for any project you want to add a Database to.
    Monday, August 9, 2010 4:06 PM
  • The reason I am expecting long file name, is because I want to place as little limitation on the creator as possible.  Some people can come up with some really long names.  I want the map projects to be under the user name so, for portability, it is easy to identify the specific user's data.

    TubbZ's suggestion of creating a database so that user names and map project names are not tied to, nor limited by, the path length limitation, would work.

    I can use C:\[path of the .exe]\User01\Project01\Level1.dms.
    Use text files for identification - using the User Name as the file name.
    Same for Project Name in the Project01 folder.
    Truncate the Indentifying text-file's name if needed, but put whole name in the body of the text file.
    When a new project is created for User01, next Project folder name will be Project02... etc.  When there is a new user, use User02 as the folder name... etc.
    (In my original post I should have shown my example as C:\[path of the .exe]\[user name]\[Project Name]\Level1.dms)

    The only thing about this is if you try to move from one computer to another running the program, then you can end up with two of the same User01 names or, worst, the receiving computer's program does not have the move recorded in it's database.

    I know that reaching the character limit, or moving the files between computers is not a very likely event, but my mind always looks for any possible future what-if problems, and then I try to give the best to the user within any given limitations.

    Monday, August 9, 2010 6:32 PM
  • You could avoid that issue by doing it slightly differently. With the folder being given a completely random name (say 20 characters long or so) Then inside the folder create a text file that contains the folders details this way if you move it then you won't have that issue unless you get really unlucky with the random file name generation and then you just look in all the folders. This way merging file systems will most likely work and a corrupted main database file will not make your entire app break as there is none.
    Tuesday, August 10, 2010 10:58 AM
  • I agree with you Tubbz.
    Sorry My Bad English
    Tuesday, August 10, 2010 11:03 AM