Re: Deleting files with ASP
From: Jim Buyens (news_at_interlacken.com)
Date: 03/08/04
- Next message: Esperanza: "Re: querystring with spaces"
- Previous message: Craig: "Frontpage 2000 modifiy web when opening??"
- In reply to: JA: "Re: Deleting files with ASP"
- Next in thread: Jim Buyens: "Re: Deleting files with ASP"
- Messages sorted by: [ date ] [ thread ]
Date: 8 Mar 2004 09:15:51 -0800
Here are some thoughts:
o Does the problem page reside in the "_folder" folder?
If not, then serverfilename="folder/filetest.txt"
wouldn't point to _folder/folder/filetest.txt and
there's your problem.
o Have you verified that NTFS permissions are correct?
Does the anonymous Web account (or whatever account you're
using) have Delete privileges?
o Are you sure you're closing the file when the Web page ends?
o How much time passes between creation of the file and the
attempt to delete it? If it's only a few seconds, IIS may be
caching the file-open state.
o Are you sure you've thought out the implications of two
visitors running this application at the same time? Could
they end up trying to use the same file at the same time?
To avoid this, you may need to use system-assigned temporary
file names, or file names based on the visitor's session ID.
Then, to clean up the per-visitor files, you delete them in
global.asa's Session_OnEnd vent and/or a timed process.
Jim Buyens
Microsoft FrontPage MVP
http://www.interlacken.com
Author of:
*----------------------------------------------------
|\---------------------------------------------------
|| Microsoft Office FrontPage 2003 Inside Out
||---------------------------------------------------
|| Web Database Development Step by Step .NET Edition
|| Microsoft FrontPage Version 2002 Inside Out
|| Faster Smarter Beginning Programming
|| (All from Microsoft Press)
|/---------------------------------------------------
*----------------------------------------------------
"JA" <jarmour@kc.rr.com> wrote in message news:<hCQ2c.3510$4B1.2158@twister.rdc-kc.rr.com>...
> Thanks, both of you, for your replies.
>
> Here is a smaller version of his logic that he made to show what is
> happening. I don't know much about this, but it looks to me like this script
> is trying to delete the file and then rewrite it. He (the programmer) has
> said that he has tried both overwriting and deleting. I can run this once,
> and the file will be created. If I run it again, I get this error:
>
> __________________________________
>
> Microsoft VBScript runtime error '800a0046'
>
> Permission denied
>
> /folder/testfiles.asp, line 10
>
> ___________________________________
>
> Only if I delete the file manually, I can run it again. Here is the script:
>
> ____________________________________
>
> <%Response.buffer=TRUE%>
> <!-- #include file="st$db.asp"-->
> <!-- #include file="fileio.asp"-->
> <%
> serverfilename="folder/filetest.txt"
> Set objFS = CreateObject("Scripting.FileSystemObject")
> serverfilename = Server.Mappath(serverfilename)
> If objfs.FileExists(serverfilename) Then
> debugwrite "deleting " & serverfilename
> objfs.deletefile(serverfilename)
> end if
> Set objFile = objFS.CreateTextFile(serverfilename)
> debugwrite "Creating " & serverfilename
> objfile.WriteLine "This is a test line"
> objfile.close
> set objfs=nothing
>
> %>
>
> ___________________________________
>
> I'm going to send him what both of you wrote. If you see something else
> wrong in the script, please let me know.
>
> Thank you!!
>
> Jill
>
>
> "Jon" <js@roksteady.net> wrote in message
> news:uhJ%23%23dKBEHA.1796@TK2MSFTNGP12.phx.gbl...
> > > This depends somewhat on how you're creating the file.
> > > For example, if you're using the
> > > Scipting.FileSystemObject's CreateTextFile method, you
> > > have to specify a second parameter such as
> > >
> > > fso.CreateTextFile("myfile.txt", true)
> > >
> > > if you want to overwrite any existing file. The default
> > > for this method, is false, meaning that the
> > > FileSystemObject won't overwrite existing files.
> >
> > Wrong way around - the default is to over-write unless you specify false.
> > For example
> > set f=oFso.createtextfile("c:\text.txt")
> > the same as
> > set f=oFso.createtextfile("c:\text.txt",true)
> > would over-write text.txt if it existed. But
> > set f=oFso.createtextfile("c:\text.txt",false)
> > would give a "file exists" error if the file already exists.
> >
> > We would need to see the code (and the exact error message) to be able to
> > help further.
> >
> > Jon
> > Microsoft MVP - FP
> >
> > Jim Buyens wrote:
> > >> -----Original Message-----
> > >> Hi,
> > >
> > > Howdy.
> > >
> > >> I am using FP 2000 on IIS4/NT. I have an asp script that
> > >> creates some files from a database. It writes from a
> > >> private subfolder ( _folder) to a subfolder of the
> > >> private subfolder ( _folder/folder).
> > >>
> > >> It will work once, but once the files are in there, I
> > >> can't run the script again and overwrite them. I get
> > >> a "permission denied" error. If I go in and manually
> > >> delete the files, it will work again.
> > >>
> > >> Neither the programmer or my ISP can figure out what is
> > >> wrong. The only other thing I can think of is a
> > >> FrontPage quirk.
> > >>
> > >> Does anyone have any ideas on this?
> > >> Thanks, Jill
> > >
> > > This depends somewhat on how you're creating the file.
> > > For example, if you're using the
> > > Scipting.FileSystemObject's CreateTextFile method, you
> > > have to specify a second parameter such as
> > >
> > > fso.CreateTextFile("myfile.txt", true)
> > >
> > > if you want to overwrite any existing file. The default
> > > for this method, is false, meaning that the
> > > FileSystemObject won't overwrite existing files.
> > >
> > > For more information on Scripting.FileSystemObject
> > > methods, browse:
> > >
> > > http://msdn.microsoft.com/library/en-us/script56/html/
> > > fsooriScriptingRun-TimeReference.asp
> > >
> > > If this doesn't point to a solution, please post again to
> > > this thread and include the exact block of code that's
> > > failing.
> > >
> > > Jim Buyens
> > > Microsoft FrontPage MVP
> > > http://www.interlacken.com
> > > Author of:
> > > *----------------------------------------------------
> > >> \---------------------------------------------------
> > >>> Microsoft Office FrontPage 2003 Inside Out
> > >>> ---------------------------------------------------
> > >>> Web Database Development Step by Step .NET Edition
> > >>> Microsoft FrontPage Version 2002 Inside Out
> > >>> Faster Smarter Beginning Programming
> > >>> (All from Microsoft Press)
> > >> /---------------------------------------------------
> > > *----------------------------------------------------
> >
> >
- Next message: Esperanza: "Re: querystring with spaces"
- Previous message: Craig: "Frontpage 2000 modifiy web when opening??"
- In reply to: JA: "Re: Deleting files with ASP"
- Next in thread: Jim Buyens: "Re: Deleting files with ASP"
- Messages sorted by: [ date ] [ thread ]
Relevant Pages
|