CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Page 2 of 2 FirstFirst 12
Results 16 to 21 of 21
  1. #16
    Join Date
    Nov 2000
    Location
    Reston, Virginia, USA
    Posts
    466

    One Line.. No Fuss No Muss


    WinExec("COMMAND.COM /C del *.txt", SW_HIDE);





  2. #17
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    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.


  3. #18
    Join Date
    Nov 2000
    Location
    Reston, Virginia, USA
    Posts
    466

    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.


  4. #19
    Join Date
    Oct 1999
    Location
    Broomfield, CO
    Posts
    3,382

    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.



  5. #20
    Join Date
    Sep 2000
    Location
    MN USA
    Posts
    11

    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

  6. #21
    Join Date
    Mar 2002
    Location
    Philadelphia
    Posts
    150
    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

Page 2 of 2 FirstFirst 12

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured