Link to home
Start Free TrialLog in
Avatar of Frisco1
Frisco1Flag for United States of America

asked on

Using CreateTextFile - How to set the path to where the file is saved on local machine.

Using the following script I can get the file saved to the local desktop just fine.

How can I specify a different location to save the file in.
i.e. C:/build/mybuild/NewFile.txt

<script language="javascript">
function WriteToFile()
{
var fso = new ActiveXObject("Scripting.FileSystemObject");
var s = fso.CreateTextFile("C:\\NewFile.txt", true);
var text=document.getElementById("TextArea1").innerText;
s.WriteLine(text);
s.WriteLine('***********************');
s.Close();
}
</script>

Your help will be appreciated.

Thank you,
frisco1
Avatar of hielo
hielo
Flag of Wallis and Futuna image

var s = fso.CreateTextFile("C:\\build\\mybuild\\NewFile.txt", true);
Avatar of Frisco1

ASKER

hielo,
Thank you for your quick answer.

It still put the file on the desktop and named it;
buildmybuildNewFile.txt

I should show you the exact line I used.
OpenWindow.document.write("var s = fso.CreateTextFile(\"C:\\atbuild\\atb\\NewFile.txt\", true);");

Please advise

Thank you,
frisco1
ASKER CERTIFIED SOLUTION
Avatar of hielo
hielo
Flag of Wallis and Futuna image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Frisco1

ASKER

hielo,
That got it - Thanks.

frisco1
Avatar of Frisco1

ASKER

I appreciate your help. Thank you