473,382 Members | 1,689 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,382 software developers and data experts.

How to detect result of FileSystemObject delete method

The delete method of the FileSystemObject.FileObject does not return a
result. If permissions disallow deletion, it will not raise an error.
Conversely, if the delete method does succeed, a call to FileExists directly
afterward may return true because the system hasn't updated yet (or whatever
actually goes on).

Is there any way to accurately check the result of a deletion?
Jul 19 '05 #1
5 7315

"Brad Wood" <bw***@colorflex.com> wrote in message
news:%2****************@TK2MSFTNGP12.phx.gbl...
The delete method of the FileSystemObject.FileObject does not return a
result. If permissions disallow deletion, it will not raise an error.

This is not true! Where did you hear this?

Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error
Ray at work
Jul 19 '05 #2
Server 2003, using the FileSystemObject in JScript within a try catch block,
I call Delete on a file I don't have permissions to delete, and the code
just keeps on cruisin; the file still exists and the code within the catch
block never executes.

Maybe you get different results when using the FileSystemObject within
VBScript?

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...

This is not true! Where did you hear this?

Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error

Jul 19 '05 #3
Can you post your code?

Ray at work

"Brad Wood" <bw***@colorflex.com> wrote in message
news:uX*************@TK2MSFTNGP10.phx.gbl...
Server 2003, using the FileSystemObject in JScript within a try catch block, I call Delete on a file I don't have permissions to delete, and the code
just keeps on cruisin; the file still exists and the code within the catch
block never executes.

Maybe you get different results when using the FileSystemObject within
VBScript?

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:%2****************@TK2MSFTNGP12.phx.gbl...

This is not true! Where did you hear this?

Error: Permission denied
Code: 800A0046
Source: Microsoft VBScript runtime error


Jul 19 '05 #4
try
{
var fsoObject = Server.CreateObject("Scripting.FileSystemObject");
// array of paths - I verified they exist
// (the files are removed if the parent folder permissions are set to
allow it)
for (var i = 0; i < deleteFileArray.length; i++)
if (fsoObject.FileExists(deleteFileArray[i]))
{
var fileObject = fsoObject.GetFile(deleteFileArray[i]);
fileObject.Delete(true);
}
}
catch(e)
{
// Never see this text - file still exists after function call (when
permissions denied)
Response.Write('Error while attempting to delete file</br>');
Response.Write(e.description);
Response.End();
}

// remove a database record here - record is deleted and user is redirected
to another
// page as specified in calling code

"Ray at <%=sLocation%> [MVP]" <myfirstname at lane34 dot com> wrote in
message news:eY*************@TK2MSFTNGP10.phx.gbl...
Can you post your code?

Jul 19 '05 #5
I'm on a W2K3 system. I tried (a modification of) your code and found that I'm throwing and catching errors. I could not see anything wrong
with your code, but my code is working as desired. Maybe there is someing you your array that's not acting correctly. I hope this helps.

My web page results:
File exist, let's delete it

Error while attempting to delete file
Permission denied

My code:

<%@language=jscript %>
<%
function DeleteIt( DeleteThis )
{
try
{
var fsoObject = Server.CreateObject("Scripting.FileSystemObject");
if ( fsoObject.FileExists( DeleteThis ))
{
Response.Write("File exist, let's delete it<br>" );
var fileObject = fsoObject.GetFile( DeleteThis );
fileObject.Delete(true);
}
Response.Write("File deleted" );
}
catch (e)
{
// Never see this text - file still exists after function call (when permissions denied)
Response.Write("<br>Error while attempting to delete file</br>");
Response.Write(e.description);
Response.End();
}
}

%>

<body>
<li></li>
<%
DeleteIt( "c:\\junk\\DeleteThis.txt")
%>
<li></li>
</body>

-rwg
This is what I think, not necessarily what is accurate!
Jul 19 '05 #6

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

9
by: MDW | last post by:
I'm not sure if this is a coding problem or an IIS settings problem. I've enabled IIS on my local machine (Windows XP SP2) so I can do some ASP development prior to rolling out my Web page to a...
6
by: hb | last post by:
Hi, Would you please tell me how to detect if the client's browser is closed? I need such event to trigger a database modification. Thank you hb
9
by: kermit | last post by:
I keep seeing that you can use the FileSystemObject in either VB script, or Javascript on an aspx page. I added a refrence to the scrrun.dll I added importing namespaces for 'System.Object',...
2
by: Luis Esteban Valencia | last post by:
I'm trying to write a little VB.NET script in an ASP.NET web page that will create folders, move files, etc... pretty much everything you can expect to do using the FileSystemObject library. Is...
5
by: phillip.s.powell | last post by:
$sql = "SELECT IF((SHOW TABLES LIKE '$subselectTableName'), count(*), NULL) AS numRows FROM $subselectTableName"; I am trying to write a SQL statement that will tell me if a table exists or not,...
3
by: ipellew | last post by:
Hi; I have a DBS that that generates some javasript and allows the user to alter table contents. If the database is being executed on a CD/DVD how can I tell is the current directory is...
1
by: cwl | last post by:
I want to get the content of a webpage containing plain text and write the content to a text file. My code looks like this: Set xmlhttp = CreateObject("Microsoft.XMLHTTP")...
1
by: G Gerard | last post by:
Hello I am using the FileSystemObject to copy files on a computer Dim MyObject as Object
3
by: brigitte | last post by:
The original problem: I need a procedure to import a csv file created by a third party application into an Access database. This file contains fields which may include commas, and when they do,...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome former...
0
by: ryjfgjl | last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
If we have dozens or hundreds of excel to import into the database, if we use the excel import function provided by database editors such as navicat, it will be extremely tedious and time-consuming...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.