By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
459,718 Members | 1,220 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 459,718 IT Pros & Developers. It's quick & easy.

FileSystemObject sees unexisting files!

P: n/a
Hi,
I use FSO ActiveXObject to save file from IE. In JS like

function saveToFile(pathN, content){
var fso, ts;
var ForWrite = 2;

fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(pathN, ForWrite, true);
ts.Write(content);
ts.close();
if (!fso.FileExists(pathN)) {
alert("The file <"+pathN+"> cannot be created.");
} else {
alert("Successfully saved");
}
}
surprisingly if the pathN contains unexisting path and the file is not
created, the fso.FileExists(pathN) still returns true (the message
"Successfully saved" is written...).

What's wrong there ?

Martin
Jul 23 '05 #1
Share this Question
Share on Google+
1 Reply


P: n/a
Lee
Martin Mrazek said:

Hi,
I use FSO ActiveXObject to save file from IE. In JS like

function saveToFile(pathN, content){
var fso, ts;
var ForWrite = 2;

fso = new ActiveXObject("Scripting.FileSystemObject");
ts = fso.OpenTextFile(pathN, ForWrite, true);
ts.Write(content);
ts.close();
if (!fso.FileExists(pathN)) {
alert("The file <"+pathN+"> cannot be created.");
} else {
alert("Successfully saved");
}
}
surprisingly if the pathN contains unexisting path and the file is not
created, the fso.FileExists(pathN) still returns true (the message
"Successfully saved" is written...).


My first guess is that at some point you're specifying the value of
pathN as a string literal that contains single backslashes, such as:

"C:\myFolder\mySubfolder\myFile.txt"

Which would succeed in creating a file named
"myFoldermySubfoldermyFile.txt" in the current directory.

Either use forward slashes or double the backslashes.

Jul 23 '05 #2

This discussion thread is closed

Replies have been disabled for this discussion.