What is the fastest way to delete ALL files in a specific directory on PPC
programatically? Thanks for answering...

Re: Deleting all files from a Directory by Ajay

Ajay
Tue Nov 22 23:41:17 CST 2005

There is no single API to delete ALL file in a specific folder on PPC. You
need to delete each file in a folder using DeleteFile() and then delete the
folder using RemoveDirectory() API.

Thanks,
-Ajay

"blue" <blue@blue.blue> wrote in message
news:%23tnMAZ97FHA.2012@TK2MSFTNGP14.phx.gbl...
> What is the fastest way to delete ALL files in a specific directory on PPC
> programatically? Thanks for answering...
>



Re: Deleting all files from a Directory by blue

blue
Wed Nov 23 09:16:46 CST 2005

> There is no single API to delete ALL file in a specific folder on PPC. You
> need to delete each file in a folder using DeleteFile() and then delete
> the folder using RemoveDirectory() API.

Yes, but how can I delete them with DeleteFile() function? I've tried the
following, but it doesn't work (eVC++ 4.0):

DeleteFile(_T("\\My Documents\\Pictures\\*.*"));

I don't know how to select all files in that directory (*.* is the usual
solution on a desktop PC, but it seems that Windows Mobile has a different
ways of doing that). Thanks!



Re: Deleting all files from a Directory by rick

rick
Wed Nov 23 09:35:06 CST 2005

you need to use FindFirstFile()/FindNextFile().


Re: Deleting all files from a Directory by Quincy

Quincy
Wed Nov 23 13:03:40 CST 2005

blue wrote:
> What is the fastest way to delete ALL files in a specific directory on PPC
> programatically? Thanks for answering...
>
>
Something like....?

Char directory[MAX_PATH];
HANDLE hFind;
WIN32_FIND_DATA fd;

strcpy(directory, "C:\Whatever");
SetCurrentDirectory(directory);

bRet=TRUE;

hFind = FindFirstFile("*.*", &fd);
while (hFind != INVALID_HANDLE_VALUE && bRet)
{
if (DeleteFile(fd.cFileName))
{
// file deleted OK
};
bRet = FindNextFile(hFind, &fd);
];
FindClose(hFind);

if(RemoveDirectory(directory))
{
// directory deleted OK
};

Code snipped from an old program of mine, but it gives you an idea.

Q