For Programmers: Free Programming Magazines  


Home > Archive > Smartphone Developer Forum > January 2005 > SHFileOperation using wildcard









You are viewing an archived Text-only version of the thread. To view this thread in it's original format and/or if you want to reply to this thread please [click here]

 

Author SHFileOperation using wildcard
TJ

2005-01-27, 3:58 am

Greetings,
I am trying to delete multiple files using the SHFileOperation api. For
the filename, I am using the wildcard *.dat to delete all the .dat files,
but I get an error saying that * is a system file and cannot be deleted.

Here is the code snippet I have done.

TCHAR szFilesToClean[MAX_PATH] = {0};
_stprintf(szFilesToClean, _T("%s\\*.%s"), _T("\Storage"), _T("dat"));

SHFILEOPSTRUCT FileOp;
ZeroMemory(&FileOp, sizeof(FileOp));
FileOp.hwnd = NULL;
FileOp.wFunc = FO_DELETE;
FileOp.fFlags = FOF_NOCONFIRMATION;
FileOp.pFrom = szFilesToClean;

SHFileOperation(&FileOp); // This call fails!

I tried with multiple combination of flags, but of no use. I am not sure
if I am doing the correct usage of the API. Actually the error dialog does
not fit in to the screen of the phone. I had to read the error message
using CE Spy tool.

MSDN documentation permits the usage of wildcards in SHFileOperation API.
I am using Windows Mobile 2003 SE. I would appreciate any kind of help or
suggestion in this issue.

Thanks,
TJ


J Ravalia [MSFT]

2005-01-27, 8:58 am

Quick Guess...
Should that be \\Storage rather than \Storage ?


--
J Ravalia
jayrava@online.microsoft.com
This posting is provided "AS IS" with no warranties, and confers no rights
"TJ" <teej@discussions.microsoft.com> wrote in message
news:uj1nSFEBFHA.2104@TK2MSFTNGP14.phx.gbl...
> Greetings,
> I am trying to delete multiple files using the SHFileOperation api. For
> the filename, I am using the wildcard *.dat to delete all the .dat files,
> but I get an error saying that * is a system file and cannot be deleted.
>
> Here is the code snippet I have done.
>
> TCHAR szFilesToClean[MAX_PATH] = {0};
> _stprintf(szFilesToClean, _T("%s\\*.%s"), _T("\Storage"), _T("dat"));
>
> SHFILEOPSTRUCT FileOp;
> ZeroMemory(&FileOp, sizeof(FileOp));
> FileOp.hwnd = NULL;
> FileOp.wFunc = FO_DELETE;
> FileOp.fFlags = FOF_NOCONFIRMATION;
> FileOp.pFrom = szFilesToClean;
>
> SHFileOperation(&FileOp); // This call fails!
>
> I tried with multiple combination of flags, but of no use. I am not
> sure
> if I am doing the correct usage of the API. Actually the error dialog
> does
> not fit in to the screen of the phone. I had to read the error message
> using CE Spy tool.
>
> MSDN documentation permits the usage of wildcards in SHFileOperation
> API.
> I am using Windows Mobile 2003 SE. I would appreciate any kind of help or
> suggestion in this issue.
>
> Thanks,
> TJ
>
>



TJ

2005-01-27, 8:58 am

I am sorry, that was \\Storage in the code, it was a typo during copying the
code from evc and pasting it here.
It is something like this.
_stprintf(szFilesToClean, _T("%s\\*.%s"), _T("\\Storage"), _T("dat"));

In my real code I am getting the two strings (the path and extension) as a
function parameter. I verified using the debugger that the pFileName param
points to an existing directory and files do exist with .dat extension.

Thanks,
TJ

"J Ravalia [MSFT]" <jayrava@online.microsoft.com> wrote in message
news:OC9zH4EBFHA.2016@TK2MSFTNGP15.phx.gbl...
> Quick Guess...
> Should that be \\Storage rather than \Storage ?
>
>
> --
> J Ravalia
> jayrava@online.microsoft.com
> This posting is provided "AS IS" with no warranties, and confers no rights
> "TJ" <teej@discussions.microsoft.com> wrote in message
> news:uj1nSFEBFHA.2104@TK2MSFTNGP14.phx.gbl...
For[color=darkred]
files,[color=darkred]
or[color=darkred]
>
>



TJ

2005-01-28, 8:59 am

Anyway, I got my things done by the classic FindFirstFile() and DeleteFile
Storage APIs. I presume, this is a bug in SP2003 SE OS itself and hope this
is fixed in Magneto.

Thanks for your reply J Ravalia.
-TJ


"TJ" <teej@discussions.microsoft.com> wrote in message
news:uOYeTIFBFHA.1452@TK2MSFTNGP11.phx.gbl...
> I am sorry, that was \\Storage in the code, it was a typo during copying

the
> code from evc and pasting it here.
> It is something like this.
> _stprintf(szFilesToClean, _T("%s\\*.%s"), _T("\\Storage"), _T("dat"));
>
> In my real code I am getting the two strings (the path and extension) as a
> function parameter. I verified using the debugger that the pFileName

param
> points to an existing directory and files do exist with .dat extension.
>
> Thanks,
> TJ
>
> "J Ravalia [MSFT]" <jayrava@online.microsoft.com> wrote in message
> news:OC9zH4EBFHA.2016@TK2MSFTNGP15.phx.gbl...
rights[color=darkred]
> For
> files,
deleted.[color=darkred]
message[color=darkred]
help[color=darkred]
> or
>
>



Sponsored Links







Also available: Server administration forum archive | Web Design forum archive | Software forum archive | Hardware reviews archive

Copyright 2008 codecomments.com