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?
<script type="text/javascript">
var fso, f1, ts, content
var ForReading = 1
var ForWriting= 2;
var ForAppending=8;
fso = new ActiveXObject("Scripting.FileSystemObject")
f1 = fso.OpenTextFile("c:\\output.ini", ForWriting);
content = f1.WriteLine("Test")
f1.close()
</script>
Thanks,
Bruce
I'm not even sure what ASP is. :) But maybe I am using it (sad isn't it, when I'm not even sure what language I'm writing in?).. up until recently I'm fairly certain it was Javascript. :) Should I be doing something differently, with regards to what I'm writing?
... 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.
Cheers,
Bruce