Scripting.FileSystemObject FileExists bug: return false for existingfiles

Z

Zhiguo

Hi, my friends:

I am using Scripting.FileSystemObject to read local files in
standalone .js application.
However, sometimes Scripting.FileSystemObject fails to read existing
files.
FileExists returns false when check file existence, and gets exception
if try to read file directly.

This happen when WPS restarts:
(1) WPS is a word processing software similar to MS Word, with similar
plugin platform also;
(2) My program is a plugin for WPS. The plugin calls a standalone .js
file with ShellExecute;
(3) The .js file read local files.
The strange thing is:
(1) when the WPS installs the plugin, the .js reads file ok.
(2) If restart WPS, the plugin again calls the .js file, then the
FileExists function of Scripting.FileSystemObject always fails.
(3) If unstall the plugin, and re-install the plugin, things are ok
again. If restart WPS, then FileExists fails again.

Why does this happen? And how to solve this problem?

Thanks in advance! Any help will be appreciated! :)

//here is my code:
function ReadAllContentFromFile(strFileName){
try{
var objFSO = new ActiveXObject("Scripting.FileSystemObject");
var vFileContent = "";
if (objFSO.FileExists(strFileName)){
var vFile = objFSO.OpenTextFile(strFileName, 1, false,0);
vFileContent = vFile.ReadAll();
vFile.Close();
}else{
vFileContent = "NOT EXIST: " + strFileName;
}
objFSO = null;
return vFileContent;
}catch(error){
return "EXCEPTION: " + error + "@" + strFileName;
}
}
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

No members online now.

Forum statistics

Threads
473,995
Messages
2,570,226
Members
46,815
Latest member
treekmostly22

Latest Threads

Top