Welcome to WebmasterWorld Guest from 18.104.22.168
Forum Moderators: open
For example, let's say the file c:\output.ini was locked.. how would I trap an error within the following code?
var fso, f1, ts, content
var ForReading = 1
var ForWriting= 2;
fso = new ActiveXObject("Scripting.FileSystemObject")
f1 = fso.OpenTextFile("c:\\output.ini", ForWriting);
content = f1.WriteLine("Test")
... but as bad as this sounds, in the end I don't think I really care what language I'm writing in. I just want to be able to trap errors (specifically writing to open files).
However, while this works locally, it should not work on the web, as it is trying to open a local file on the users machine. Security prevents a client-side script from accessing files on the client machine.
You need to look at server side scripting to read from/write to files on the web server.
I guess that's what I'm getting at, the intention is to just have it run locally. This script will never run anywhere other than on a local machine. But what I'm concerned about is either:
a.) The file not writing properly because it's already opened.
b.) An error message appearing when writing to/opening a file because the file is already opened.
and I was looking for a way to trap that error, given that I'm running this entire thing locally.