Article View: borland.public.cppbuilder.nativeapi
Article #17299Re: Problem in deleting file!
From: Remy Lebeau (TeamB)
Date: Fri, 28 Mar 2003 09:08
Date: Fri, 28 Mar 2003 09:08
44 lines
2136 bytes
2136 bytes
"Safari" <Safari@alloymail.com> wrote in message
news:3E8408FF.5040308@alloymail.com...
> hFile.pFrom = hPath;
The pFrom and pTo members must be double-null terminated, but you're not
providing a second null terminator at all. Try this instead:
bool __fastcall RemoveFile(AnsiString Path)
{
Path += '\0';
SHFILEOPSTRUCT hFile = {0};
hFile.wFunc = FO_DELETE;
hFile.pFrom = Path.c_str();
hFile.fFlags = FOF_SILENT | FOF_NOCONFIRMATION | FOF_NOERRORUI;
return SHFileOperation(&hFile);
}
void __fastcall TMain::BitBtn4Click(TObject *Sender)
{
for (int a = ListView->Items->Count - 1; a >= 0; a--)
{
TListItem *Item = ListView->Items->Item[a];
RemoveFile(Item->Caption);
Item->Delete();
}
}
Or, just use DeleteFile() instead:
void __fastcall TMain::BitBtn4Click(TObject *Sender)
{
for (int a = ListView->Items->Count - 1; a >= 0; a--)
{
TListItem *Item = ListView->Items->Item[a];
DeleteFile(Item->Caption);
Item->Delete();
}
}
Gambit
Technical Details
Message-ID:
<3e840eac$1@newsgroups.borland.com>Path:
arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mailReferences:
<3E8408FF.5040308@alloymail.com>Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII-7-bit X-Google-Thread: 10cc67,5fde27ba165b16db X-Google-Attributes: gid10cc67,public X-Google-ArrivalTime: 2003-03-28 01:08:01 PST From: "Remy Lebeau \(TeamB\)" <gambit47@yahoo.com> Newsgroups: borland.public.cppbuilder.nativeapi References: <3E8408FF.5040308@alloymail.com> Subject: Re: Problem in deleting file! Date: Fri, 28 Mar 2003 01:08:19 -0800 Lines: 46 X-Priority: 3 X-MSMail-Priority: Normal X-Newsreader: Microsoft Outlook Express 6.00.2800.1106 X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106 NNTP-Posting-Host: 207.175.226.26 Message-ID: <3e840eac$1@newsgroups.borland.com> X-Trace: newsgroups.borland.com 1048841900 207.175.226.26 (28 Mar 2003 00:58:20 -0800) Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-03!sn-xit-06!sn-xit-09!supernews.com!iad-peer.news.verio.net!news.verio.net!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail