๐Ÿš€ go-pugleaf

RetroBBS NetNews Server

Inspired by RockSolid Light RIP Retro Guy

Article View: borland.public.cppbuilder.nativeapi
Article #17311

Re: Problem in deleting file!

#17311
From: nicolasr
Date: Fri, 28 Mar 2003 20:15
82 lines
3086 bytes
Hi,
if I understand correctly you want to pass the your path as a char*. But as
Remy told you the path needs a double \0 at the end. So either you pass a
char* to your RemoveFile that is already double \0 terminated or you copy it
inside the RemoveFile body to a local char array and add a second \0.

Sketch:

bool __fastcall RemoveFile(char *hPath)
{
   char buffer[MAX_PATH+1];
   strcpy(buffer, hPath);
   buffer[strlen(hPath)+1] = '\0';
   ...
   hFile.pFrom  = buffer;

   ...

}

regards,
Nick





"Safari" <Safari@alloymail.com> escribi๏ฟฝ en el mensaje
news:3E842BD0.1060302@alloymail.com...
> Thanks Mr. Dear Remy,
> Can not i use "char *Path" and ".pFrom = Path"?
> Safari
>
> Remy Lebeau (TeamB) wrote:
> > "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: <3e84ad5c$1@newsgroups.borland.com>
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail
References: <3E8408FF.5040308@alloymail.com> <3e840eac$1@newsgroups.borland.com> <3E842BD0.1060302@alloymail.com>

Show Full Headers
Complete Article Headers
X-Google-Language: ENGLISH,ASCII
X-Google-Thread: 10cc67,5fde27ba165b16db
X-Google-Attributes: gid10cc67,public
X-Google-ArrivalTime: 2003-03-28 12:22:27 PST
From: "nicolasr" <nicolasrNOSPAMATSIGNgmx.net>
Newsgroups: borland.public.cppbuilder.nativeapi
References: <3E8408FF.5040308@alloymail.com> <3e840eac$1@newsgroups.borland.com> <3E842BD0.1060302@alloymail.com>
Subject: Re: Problem in deleting file!
Date: Fri, 28 Mar 2003 21:15:33 +0100
Lines: 84
X-Priority: 3
X-MSMail-Priority: Normal
X-Newsreader: Microsoft Outlook Express 6.00.2720.3000
X-MimeOLE: Produced By Microsoft MimeOLE V6.00.2800.1106
NNTP-Posting-Host: 80.133.173.44
Message-ID: <3e84ad5c$1@newsgroups.borland.com>
X-Trace: newsgroups.borland.com 1048882524 80.133.173.44 (28 Mar 2003 12:15:24 -0800)
Path: arc1-ca.pugleaf.net!archiver1.google.com!news1.google.com!sn-xit-02!sn-xit-06!sn-xit-08!supernews.com!newsfeed.wirehub.nl!news.kweb.on.ca!KWeb!newsgroups.borland.com!not-for-mail