Controlling the Deletion of a File

From: Struggling Rod (StrugglingRod_at_discussions.microsoft.com)
Date: 02/25/05


Date: Fri, 25 Feb 2005 10:33:03 -0800

I am writing a generic subroutine in VB6 to delete a file. The subroutine
needs to check the file to make sure it's deletable. For example, the file
shouldn't be already open or locked. I plan to use the File System Object's
method "DeleteFile" to delete a file.

How do I check whether a file is already open or locked?

What file attributes indicate that a file is OK to delete? I suspect I would
want to limit the attributes only to Normal or ReadOnly. I know various
constants that attributes can be: 0 = Normal, 1 = ReadOnly, 2 = Hidden, etc.,
up to 64 = Alias. Are there any more values?

I believe there is also an attribute for a Compressed file--what is the
value of this attribute?

I have a certain file whose attribute value is 8192. What does this value
mean?

In general, I would like to know under what specific conditions I shouldn't
delete a file and how I test these conditions.

is there already such a subroutine written? If so, can someone direct me to
its code?



Relevant Pages

  • Re: recurse subdirectories without using File::Find
    ... Why are you ignoring a known non-buggy solution in favor of ... You start by writing better code, and asking Perl for help whenever you ... Why are you calling the subroutine with the & on front? ...
    (perl.beginners)
  • Re: writing drivers using C++
    ... You are trying to sidestep the issue by writing about something ... coding against an interface - when the implementation starts mattering to ... Every subroutine invokation has to be coded manually, ...
    (comp.os.linux.development.system)
  • Re: [QUIZ][SOLUTION] Kalah (#58)
    ... preceding URL makes it look harder and more cumbersome than just writing a ... subroutine to exercise your new class. ...
    (comp.lang.ruby)
  • Re: use go to doing some case studies and induced problems
    ... these case studies are not so worthy of writing them as ... If for some reason I really didn't want a separate routine with an argument list, I'd use an internal subroutine. ... Anything so short that it's not worth making a subroutine for, I'd put inline in the code. ... I'd have to say, this sounds like it could easily lead to GIGO (garbage in, garbage out) when you miss something in the logic. ...
    (comp.lang.fortran)
  • Re: solving an equation multiple directions
    ... On Fri, 16 Jan 2009, Jason wrote: ... writing the equation twice. ... but without writing two equations to prevent duplication in my code. ... Perhaps you want a subroutine. ...
    (sci.math)