How to set a filepath that is computer independent?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • Joey de Vries
    New Member
    • Jan 2011
    • 3

    How to set a filepath that is computer independent?

    Good Day,

    I'm currently working on a project with the Google Earth API and one method in the API goes as follows:

    ge.OpenKmlFile( "C:/Users/Joey/Documents/C/Google Earth Form/Google Earth Form/bin/Debug/JoeyTest.kml", 1);

    As you can see I'm using the complete pathname to get to my .kml test file, but the method won't accept a string as : "/JoeyTest.kml" or "JoeyTest.K ml" or any other synonym for getting a file out of the exact same folder.

    Is the parameter for the file name dependend on how the method has been written or is there any way to turn it into a computer independend pathname?

    When I try to install my C# Application onto a different computer, the file won't be read unless I change the filename again. This isn't the way I want to approach the users to read a file intro Google Earth.

    Any help would be greatly appreciated!

    King regards,
    Joey =)
  • hype261
    New Member
    • Apr 2010
    • 207

    #2
    I would use one of the SpecialFolder enums to set the path.

    System.Environm ent.GetFolderPa th(Environment. SpecialFolder);

    Here is link to what values you can use with the SpecialFolder enum

    Specifies enumerated Constant Special Item ID List (CSIDL) values used to retrieve directory paths to system special folders.

    Comment

    • Joey de Vries
      New Member
      • Jan 2011
      • 3

      #3
      Thanks for the quick reply.. I'll look into your option and sse if I can figure it out! Thanks ^^

      Comment

      • Joey de Vries
        New Member
        • Jan 2011
        • 3

        #4
        Oké it seemed to work. Couldn't create a new folder in my documents though via the assignment.

        Are the files temporary or something? Cause after i've initialized my program there doesn't seem to be any files in 'My documents' while the program IS reading the file from 'My Documents'?

        Comment

        Working...