Link to home
Start Free TrialLog in
Avatar of vsp
vsp

asked on

ASP problem

Using JavaScript, the CreateTextFile()/OpenTextFile()
does not work right. It always gives me "Permission Denied" when I try
to create a file. But the same thing works fine with VBScript. Can you
tell me what's wrong that I'm doing ?
ASKER CERTIFIED SOLUTION
Avatar of theTerabyte
theTerabyte

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 vsp
vsp

ASKER

I wish, the answer would have told me how to create the text file in JavaScript. It is a rather incomplete answer.
sorry, let me look at it and try to give you more info....
Explain how CreateTextFile() and OpenTextFile() is supposed to work, i.e. arguments and such, and i'll try to figure out why it won't work.  It must be the ONE function not covered in my JS book.  However, I was able to answer you question(kinda) from general JavaScript history and knoledge about the history of the language.  
One of the main reasons many browsers didn't support JS or Java until recently is because they were worried it wasn't secure enough, it is someone's program who you don't know that is running on unsuspecting client's machines.  That's why netscape by default warns you about JS and Java, and it can be disabled.  The first versions were pretty buggy and it was very possible, especially in Java, that one could read file of a client's hard drive or network and relay them to a server(uhh oh).  But, as you know can see, those "problems" have been fixed for the most part(i.e. perm errors).
Avatar of vsp

ASKER

I appreciate your concern on answering my question, thanks !
The CreateTextFile() is supposed to create a text file with these arguments;
      CreateTextFile ("fname",createFlag,permissions)
where:
      createFlag - create a file if non-exsistant, otherwise overwrite.
      permissions- permissions given to the file

FYI-This works okay in VBScript with any combinations of these arguments.

With OpenTextFile(), the story is stightly different.It does not work in JScript but in VBScript these two forms do not work

      Set tf = fs.OpenTextFile ("e:\textFile.txt",1,TRUE,0)

In these it complains of invalid argument TRUE.

      Set tf = fs.OpenTextFile("e:\txtFile.txt", 0,0,0)
      tf.WriteLine("This is a test")

It says "Permission Denied". In this case we are trying to append to a pre-exsistant file.

I have added lot of extra infomation in this comment, which may help you debug the problem.

Thanks, in advance.
Alright, i've sone some testing, and i'm sorry to say, I don't know why it dosen't work or how to fix it, but I do know the reason is related to JS' Security features.  To do any more testing i'd need the HTML file you're using it in.  If you can send it to me, i might be able to look at it again.....