Re: file delete routine is intermittent




"Steve Easton" <admin@xxxxxxxxxxxxx> wrote in message
news:%23AiLRTPRFHA.1564@xxxxxxxxxxxxxxxxxxxxxxx
> Having problems with the following trying to move files to the recycle
bin.
> It doesn't move all of the files. Any ideas??
>
> FOF_FLAGS = GetOptionFlags()
> For i = 1 To filenames.Count
> file2delete = filenames(i)
> With shf
> .wFunc = FO_DELETE 'action to take place
> .pFrom = file2delete 'the file to delete

The problem is likley in the above snippet. You must double-null terminate
the pFrom member. If you don't, SHFileOperation is ...unpredictable at best.

Try this:

..pFrom = file2delete & vbNullChar & vbNullChar 'the file to delete

For more information, see the Platform SDK on the SHFILEOPSTRUCT structure,
which states for the pFrom member:

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.


--
Mike
Microsoft MVP Visual Basic



.



Relevant Pages

  • Re: file delete routine is intermittent
    ... I've tried it adding one null character and two null characters and the results are the ... > For more information, see the Platform SDK on the SHFILEOPSTRUCT structure, ... > which states for the pFrom member: ... it is used as a buffer to hold multiple file names. ...
    (microsoft.public.vb.winapi)
  • Re: file delete routine is intermittent
    ... *.* for the pFrom member and do away with finding the file names and the ... > Hi Mike, ... > I've tried it adding one null character and two null characters and the ... >> Address of a buffer to specify one or more source file names. ...
    (microsoft.public.vb.winapi)