|
-
November 21st, 2000, 04:16 PM
#16
One Line.. No Fuss No Muss
WinExec("COMMAND.COM /C del *.txt", SW_HIDE);
-
November 21st, 2000, 04:28 PM
#17
Re: File Removal with a wildcard
Download/install the latest Platform SDK. Then, using Tools/Options/Directories in the Visual Studio menu, add the SDK include and lib paths to the top of their respective lists. Rebuild All.
-
November 21st, 2000, 04:38 PM
#18
Re: File Removal with a wildcard
if you happen to have a broad band connection that allows you to down load a 300+ meg file and also happen to have the extra gig or so free hd space to compile the sdk...
Breakdown and use the winexec call, one line no fuss no muss.
-
November 21st, 2000, 05:09 PM
#19
Re: File Removal with a wildcard
You're overstating the case.
I have the SDK installed, including many of the samples, and it takes 500 Meg, not 1 Gig. Nothing needs to be compiled in the SDK in order to use it. Just put the include and lib directories under your Options settings.
And some things are only defined in the SDK, such as FOF_NORECURSION.
So, yes, WinExec could be used in this case, but having the Platform SDK installed could end up being required if you need to use certain functions or COM interfaces.
-
November 23rd, 2000, 05:58 PM
#20
Re: File Removal with a wildcard
Briefly, I used SetCurrentDirectory to go to the folders and kept pFrom with the 8.3 format. I then added the still current flags for auto confirming and pop-up silence and all worked.
I thought I fully conformed to using the no long filename requirements, but apparently not. I don't think I misswd any \" escapes to pass, but anyway it now all performs as expected with the shell operation functions.
The 1026 message pops up with any discrepency such as not having a file to delete.
Thanks for assistance.
Remove "spamnot" to use e-mail
-
July 23rd, 2004, 11:01 AM
#21
try
Code:
void DeleteFiles(const TCHAR* tszFullPathFileNamePattern)
{
HANDLE hFile = NULL; // Handle to file
WIN32_FIND_DATA FileInformation; // File information
BOOL br = FALSE;
CString strFileName;
CString strFolderName;
CString strTemp = tszFullPathFileNamePattern;
int index = strTemp.ReverseFind('\\');
if(index>=0)
{
strFolderName = strTemp.Mid(0, index+1);
}
hFile = ::FindFirstFile(tszFullPathFileNamePattern, &FileInformation);
if(hFile != INVALID_HANDLE_VALUE)
{
do
{
if(!(FILE_ATTRIBUTE_DIRECTORY & FileInformation.dwFileAttributes))
{
strFileName = strFolderName + FileInformation.cFileName;
br = DeleteFile(strFileName);
}
} while(::FindNextFile(hFile, &FileInformation));
::FindClose(hFile);// Close handle
}
}
call it as follows:
Code:
// Delete files Crystal Reports leaves in the Temp Directory
TCHAR* tszTempDir = _tgetenv("TEMP");
CString strTempDir = tszTempDir;
DeleteFiles(strTempDir+_T("\\CPE*.tmp"));
DeleteFiles(strTempDir+_T("\\~DFB*.tmp"));
DeleteFiles(strTempDir+_T("\\ACR*.tmp"));
Sincerely,
- Ron
Posting Permissions
- You may not post new threads
- You may not post replies
- You may not post attachments
- You may not edit your posts
-
Forum Rules
|
Click Here to Expand Forum to Full Width
|