PC Review


Reply
Thread Tools Rate Thread

Delete a file using copy to bit bucket

 
 
News@InsightfulMES.com
Guest
Posts: n/a
 
      20th Sep 2005
Is it possible to delete a file by copying it to the "bit bucket" or
"null device"?

Back in my youth when I live in VMS-land you could delete a file by
copying it to NL:

==========

I have written a windows service as part of an interface between two
different systems. The first system will write output into a file in a
shared folder. The server will detect the new file(s) and process
them.

If the second system is updated successfully the file is moved to a
"success" folder and if not it is move to a "failure" folder.
Eventully there will be a huge number of files in the success folder.
The source, success and failure folders are specified in a config file.
Once the user is satisified that the process is working they would
like to just delete the successfull files but still keep the option to
return to moving them to the success folder. The easiest way to do
this, without any code changes, is to just specify the success folder
as the "bit bucket" or "null device", then the copy would just send the
file off into the ether.

Mike Buchanan

 
Reply With Quote
 
 
 
 
Peter Rilling
Guest
Posts: n/a
 
      21st Sep 2005
No.

Copy does just that, copy the contents. I am so glad the coping a file does
not remove it.


<(E-Mail Removed)> wrote in message
news:(E-Mail Removed)...
> Is it possible to delete a file by copying it to the "bit bucket" or
> "null device"?
>
> Back in my youth when I live in VMS-land you could delete a file by
> copying it to NL:
>
> ==========
>
> I have written a windows service as part of an interface between two
> different systems. The first system will write output into a file in a
> shared folder. The server will detect the new file(s) and process
> them.
>
> If the second system is updated successfully the file is moved to a
> "success" folder and if not it is move to a "failure" folder.
> Eventully there will be a huge number of files in the success folder.
> The source, success and failure folders are specified in a config file.
> Once the user is satisified that the process is working they would
> like to just delete the successfull files but still keep the option to
> return to moving them to the success folder. The easiest way to do
> this, without any code changes, is to just specify the success folder
> as the "bit bucket" or "null device", then the copy would just send the
> file off into the ether.
>
> Mike Buchanan
>



 
Reply With Quote
 
=?ISO-8859-1?Q?Lasse_V=E5gs=E6ther_Karlsen?=
Guest
Posts: n/a
 
      21st Sep 2005
(E-Mail Removed) wrote:
> Is it possible to delete a file by copying it to the "bit bucket" or
> "null device"?

<snip>

Just a comment to your service. I've implemented several such services
in various ways and one thing I've found is that it's impossible for me
to guarantee that the system will work in all situations.

There could be a multitude of sources for errors that can crop up and at
some point you're going to loose a file, or try to figure out wether a
file was processed or not.

I found that by always moving the file to a "successful" directory after
processing it, or an "error" directory in case of problems, the user
always knows that whatever happens (network problems, database
crash/rollback/restore, disk full, etc.) they can always find their
files and just move them back into the processing directory to reprocess
them.

The problem I was left with then was that this directory quickly filled
up, but after a time, old files are no longer interesting nor necessary
so I just added code to the service to take a look in this directory
from time to time and delete all files older than X days (14 in most
cases) to keep its size down.

In any case, a simple change for your program would be that your program
accepts an empty directory name as the successful target, and in that
case the program just uses File.Delete to remove the file instead of
File.Move.

--
Lasse Vågsæther Karlsen
http://www.vkarlsen.no/
private.php?do=newpm&u=
PGP KeyID: 0x2A42A1C2
 
Reply With Quote
 
Ignacio Machin \( .NET/ C# MVP \)
Guest
Posts: n/a
 
      21st Sep 2005
Hi,

> Back in my youth when I live in VMS-land you could delete a file by
> copying it to NL:


Copying or moving it?
I never worked in VMS, but in *NIX you could do that, move the file th
/dev/null


> If the second system is updated successfully the file is moved to a
> "success" folder and if not it is move to a "failure" folder.
> Eventully there will be a huge number of files in the success folder.
> The source, success and failure folders are specified in a config file.
> Once the user is satisified that the process is working they would
> like to just delete the successfull files but still keep the option to
> return to moving them to the success folder. The easiest way to do
> this, without any code changes, is to just specify the success folder
> as the "bit bucket" or "null device", then the copy would just send the
> file off into the ether.
>
> Mike Buchanan
>


Well, your problem could be solver with a simple config var and an if
construction:

if ( Configuration.AppSettings["DeleteSuccess"] == "yes" )
{
// proceed to delete it.
}


I have a similar situation, only that I keep the files a number of days, I
delete them after a certain number of days.

does that solve your problem ?


 
Reply With Quote
 
 
 
Reply

Thread Tools
Rate This Thread
Rate This Thread:

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off
Trackbacks are On
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Internet Explorer 0 22nd Apr 2011 10:08 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Networking 0 22nd Apr 2011 10:07 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Setup 0 22nd Apr 2011 10:06 AM
http://LongPathTool.com - find and delete/copy path too long filesfrom your hard drive or LAN Windows tool to copy or delete files and folderswith path too long or filename too long error. Just browse to the file andpress a button to copy or d Martin Krag Windows XP Configuration 0 22nd Apr 2011 10:05 AM


Features
 

Advertising
 

Newsgroups
 


All times are GMT +1. The time now is 10:33 PM.