Re: file delete routine is intermittent

Tech-Archive recommends: Repair Windows Errors & Optimize Windows Performance



Mike,

> Try this:
>
> .pFrom = file2delete & vbNullChar & vbNullChar 'the file to delete

This is not necessary as Visual Basic automatically appends a single null
terminator character to every string.

I wondered about the double terminator at the end, that could be a problem.
However, if SHFileOperation didn't find a double terminator, it would
attempt to delete additional filenames and wouldn't skip filenames as the OP
complained about.

> pFrom
> Address of a buffer to specify one or more source file names. These names
> must be fully qualified paths. Standard DOS wild cards, such as "*", are
> permitted in the filename position. Although this member is declared as a
> null-terminated string, it is used as a buffer to hold multiple file
names.
> Each file name must be terminated by a single NULL character. An
additional
> NULL character must be appended to the end of the final name to indicate
the
> end of pFrom.

Sounds like his best bet is to simply pass the wildcard specification to
SHFileOperation instead of locating matching filenames himself. He may also
want to use my wrapper class as that deals with some other potential
problems.

--
Jonathan Wood
SoftCircuits
http://www.softcircuits.com
Available for consulting: http://www.softcircuits.com/jwood/resume.htm


.



Relevant Pages

  • Re: left$, mid$ and right$ (was: ANN: pldev.org)
    ... Not a type, no, but it does have the concept of "character string". ... regarding the terminator being a character or a byte. ... "C treats strings as arrays of characters conventionally terminated ...
    (comp.lang.misc)
  • Re: file delete routine is intermittent
    ... >> terminator character to every string. ... > Only when you pass a string as a parameter. ... VB does NOT automatically append a null ...
    (microsoft.public.vb.winapi)
  • Re: file delete routine is intermittent
    ... >>> terminator character to every string. ... >> Only when you pass a string as a parameter. ... >> character to string members of structures so you must append the null ...
    (microsoft.public.vb.winapi)
  • Re: file delete routine is intermittent
    ... that indicate the current folder and parent folder? ... I wondered about the double terminator at the end, ... attempt to delete additional filenames and wouldn't skip filenames as the OP ... > Each file name must be terminated by a single NULL character. ...
    (microsoft.public.vb.winapi)
  • Re: file delete routine is intermittent
    ... > that indicate the current folder and parent folder? ... > I wondered about the double terminator at the end, ... > attempt to delete additional filenames and wouldn't skip filenames as the OP ... >> Each file name must be terminated by a single NULL character. ...
    (microsoft.public.vb.winapi)