Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Permission Denied on FSO.Write statement

Status
Not open for further replies.

jeepxo

Programmer
Oct 1, 2002
228
CA
Here's my scenario.

I have a PDF form that gets populated dynamically by XFDF files.
I create the XFDFs when needed using

myFSO.CreateTextFile(myFileName,true)

Works great first through. My problem occurs when you try to do this multiple times.

We get a
Microsoft JScript runtime error '800a0046'

Permission denied

/fso.asp, line 150

What I am guessing is happening is the asp page creates the XFDF file like it is suppose to, but is not releasing it afterward.

Here's my code

Code:
myFSO = Server.CreateObject("Scripting.filesystemobject")

myFSO.CreateTextFile(myFileName,true)
	myWorkingText = myFSO.openTextFile(myFileName,ForWriting,true)
	myWorkingText.write('<?xml version="1.0" encoding="UTF-8"?>');
	myWorkingText.write('<xfdf xmlns="[URL unfurl="true"]http://ns.adobe.com/xfdf/"[/URL] xml:space="preserve">');
.
.
.
myWorkingText.write('</fields></xfdf>');
myWorkingText.Close();
myWorkingText = null;

Is there something I am missing to get the web server to release the XFDF file to be written to or deleted again quickly?

&quot;Every day is like a precious gift, you have to make it count&quot; James Birrell 1993-2001
 
one thing I forgot to mention

I check to see if the file exists already using this.

Code:
if (myFSO.FileExists(myRootFolder + "\\" + myFileName + ".xfdf"))
	{
		myFSO.DeleteFile(myRootFolder + "\\" + myFileName + ".xfdf")
	}
	createXFLFFile();

&quot;Every day is like a precious gift, you have to make it count&quot; James Birrell 1993-2001
 
Double check the permissions on the folder to make sure that the generic IIS user has write permission (user should be something like IUSR_MachineName)

I don't think that is an issue as the error is occuring the second/third/nth time through, but it is worth checking.

My first real guess would be that you might have an open file handle due to the CreatetextFile call. CreateTextFile opens a textstream to the newly created file, but since your not using it (and not closing it yourself) that text stream may be stuck in limbo waiting for cleanup...although I would assume that the call to open the text file would fail the first time if it were going to fail during later calls.

Try condensing your code a little just in case, change:
Code:
myFSO.CreateTextFile(myFileName,true)
    myWorkingText = myFSO.openTextFile(myFileName,ForWriting,true)

[b]to[/b]

myWorkingText = myFSO.CreateTextFile(myFileName,true)

Also, make sure you have setyour FSO object to null when your done with it also, you might be getting hangups by not forcing it to be released in a timely manner (similar to what happens when you have ADO command objects active and rely on IIS to clean them up for you, updates sometimes don't happen until after the next page is loaded).

-T

barcode_1.gif
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top