Announcement

Collapse
No announcement yet.

Verify file exists for current installation directory

Collapse
X
 
  • Filter
  • Time
  • Show
Clear All
new posts

  • Verify file exists for current installation directory

    I am creating a script using File.DoesExist to check that a file exists to prevent installing to the wrong location. I thought i was finished as it seems to work. But i realized this checks the file on the system and not the current directory entered in the installation field. i am now trying to use Folder.Find as this has a callbackfunction for currentpath. But i am still having issues and need a little help.

  • #2
    Originally posted by DevoTaylor View Post
    this checks the file on the system and not the current directory entered in the installation field
    Please post the relevant code to understand what you are doing - and explain clearly what you want to do.

    Ulrich

    Comment


    • #3
      Here is my code that works for checking the entire computer. But i need make it only check the current directory.

      Code:
       -- required files to continue
      
       -- Folders
      
      -- Check to see if a specific folder exists.
      folder_exist = Folder.DoesExist("%FSXFiles%".. "\\SimObjects\\Airplanes");
      -- Display a dialog telling the user whether or not the folder exists.
      if folder_exist == false then
              Screen.Jump("Wrong Location");
      else

      Comment


      • #4
        Let me re-phrase that. Not current directory. Checking the entire computer directory is not what i want. I want to check the current installation field the user has entered. this way they can't install to any location.

        Comment


        • #5
          I am trying this but no luck...

          Code:
           
           folder_exist = Folder.DoesExist(Folder.GetCurrent("%FSXFiles%".. "\\SimObjects\\Airplanes"));

          Comment


          • #6
            Originally posted by Ulrich View Post

            Please post the relevant code to understand what you are doing - and explain clearly what you want to do.

            Ulrich

            SOLVED: Unless there is another method this seemed to work and the code change was simple.

            I changed the registry session variable to the main AppFolder session variable. Seems the AppFolder is the current directory in the installation field.

            Code:
             
              -- required files to continue   -- Folders  -- Check to see if a specific folder exists. folder_exist = Folder.DoesExist("%AppFolder%".. "\\SimObjects\\Airplanes"); -- Display a dialog telling the user whether or not the folder exists. if folder_exist == false then         Screen.Jump("Wrong Location"); else

            Comment


            • #7
              You are not expanding the session variable. Please see the FAQ or refer to the sample code in the product documentation.
              https://forums.indigorose.com/forum/...variables-work

              Ulrich

              Comment


              • #8
                Not sure if you saw my last post. I did solve my issue. The reason i am not expanding the default session variable %AppFolder% is because i am not sure the string will work in the above code i use. Also if the user changes the directory the %AppFolder% i have set from the registry will not match and they will be able to install to the wrong location.

                Again i could be wrong but it does work. So any reason i want to expand it?

                Comment


                • #9
                  If you want to write a script which actually works and does not return the same result no matter the current contents of the session variable, then you need to expand it in order to be able to use it in the action.

                  Ulrich

                  Comment


                  • #10
                    Yes normally a session variable is static because you have a value entered from the session variable settings. So you do want to expand it to use it. But in my case we do not use the settings page we inject the value from our start program option. So what happens is we offer the user to be able to change the destination field if their registry is not up to date anymore and they moved their sim to another drive or location and the registry never got updated. So when they change the destination the %AppFolder% value changes to the new location they just chose. I have tested this and if i use the static value this will not prevent my working code from them installing to any location they want. Our goal is for security and so they do not accidentally install to the wrong location. So after hours of testing only using the session variable works.

                    Also i thought the point of a session variable was to be able to use the short code so you do not have to enter a long value.

                    Comment

                    Working...
                    X