Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 9047001
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 16, 20262026-06-16T11:47:45+00:00 2026-06-16T11:47:45+00:00

I created a variable to hold a relative path because I cannot have a

  • 0

I created a variable to hold a relative path because I cannot have a direct path since this will be installed on different PCs.

var mainUrlCONST = "../../annotations/annotate.xml";

When the initial page of the program loads, it checks to see if the file exists.
If it does not, it creates it.

Now here-in lies the problem, it reads from exactly where I want it to, but if it does not
see the file there, it creates it somewhere else on the PC instead of the location I specified.

This checks for the file:

function initializeAnnotationFile()
{
    try
    {
        var connection = new ActiveXObject("Microsoft.XMLHTTP");
        connection.open("GET", mainUrlCONST, false);
        connection.send();

        if ( connection.readyState == 4 )
        {
        response = connection.responseText;
        }

        xml = response; 
        mainExists = true;
    }
        catch(e)
    {
        mainExists = false; 
    }
}

This creates the file if it does not exist:

function createAnnotationFile()
{
    var fso = new ActiveXObject("Scripting.FileSystemObject");
    var s = fso.CreateTextFile(mainUrlCONST, true);

    s.WriteLine( "<list>" );
    s.WriteLine( "  <section title='Annotations'>" );
    s.WriteLine( "  </section>" );
    s.WriteLine( "</list>" );
}

Here is the direct path that works, if it will help any.

var mainUrlCONST = "G:/folder/annotations/annotate.xml";
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-16T11:47:46+00:00Added an answer on June 16, 2026 at 11:47 am

    There has been problems with FSO and relative paths. All documentation says, that paths can be either absolute or relative, but personally I never have got relative paths to work.

    I’m using an installation folder -based addressing system in my local apps. A simplified version is something like this:

    function getInstallBase() {
        var defInstal = 'Application_installation_folder_name',
            selfPath = window.location.pathname.replace(/\\/g,'/');
        if (selfPath.charAt(0) === '/') { // *
            selfPath = selfPath.substring(1, selfPath.length);
        }
        selfPath = selfPath.split(defInstal);
        return selfPath[0] + defInstal + '/';   
    }
    var defRoot = getInstallBase();
    

    * = IE returns /G:/… when HTA returns G:/…

    defRoot now contains an absolute path to the installation folder, no matter where it is saved.

    Put this code to a JS-file in the installation folder of your application. Where ever you need a path, provide it based on defRoot i.e. counted from the installation folder. In your case (assuming folder is the installation folder) you can use it like this:

    var s = fso.CreateTextFile(defRoot + 'annotations/annotate.xml', true);
    

    I’ve used this technique for portable apps, and it works like a charm. You can make executable copies to memory sticks, CDs, DVDs, where ever you want, without need to touch the code at all.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have created a function which tells whether a variable hold jQuery object or
I have created a class for a dashboard item which will hold information such
I have a list of class object that I created as a variable in
I have created a servlet that passes a string variable strname to a JSP
I have a workflow that is created in code and a variable of type
In a makefile, I define a variable using the define directive. This variable will
I have created a notes field designed to hold multiple paragraphs of text which
I created an instance variable ( @edit_id ) in the user_controller the update action.
I am trying to created nested dictionary variable like the below, But I get
I created a class that extends DefaultMutableTreeNode. It has a variable, resource of the

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.