Welcome To The Home Of The Visual FoxPro Experts  
home. signup. forum. archives. search. google. articles. downloads. faq. members. weblogs. file info. rss.
 From: Mike Yearwood
  Where is Mike Yearwood?
 Toronto
 Canada
 Mike Yearwood
 To: Sajan Jacob
  Where is Sajan Jacob?
 mumbai
 India
 Sajan Jacob
 Tags
Subject: RE: Temporary Cursor Locations
Thread ID: 311148 Message ID: 311208 # Views: 31 # Ratings: 0
Version: Visual FoxPro 9 SP2 Category: Projects and Design
Date: Wednesday, June 29, 2011 5:11:37 PM         
   


> >
> > Theny should be deleted when you close them, no matter if you exit the form/application or not:
> >
> > CREATE CURSOR crsTest (Fld1 I)
> > 
> > USE IN crsTest  && At this point the cursor should be deleted.
> > 

> > of course when you exit the form with private datasession or exit the application theese cursors are colsed by VFP and that way they are deleted.
> >
> >
> > -----------------
> > Borislav Borissov
> >
> > Against Stupidity the Gods themselves Contend in Vain - Johann Christoph Friedrich von Schiller
> > The only thing normal about database guys is their tables.
>
> I found many .TMP files in the users application data..temporary folder. I think even after exit from the application, these files are still saved it it the folder..
>
> Sajan

If the users are not exiting the application properly. If they ctrl+alt+del .TMP files will remain. You cannot delete them at exit, because user can Ctrl+alt+del. You have to delete at application start. Since VFP will make new .tmp files, you need try...catch.

LPARAMETERS m.tcFolderName,m.tcDeleteFileSkeletons
*
*  DELETEFILES.PRG
*
*  Deletes all files according to the specified delete
*  file skeletons in the specified folder. Intended
*  specifically to delete VFP temporary files.
*
*  RETURNs the number of files successfully deleted.
*
*  Author:  Mike Yearwood
*
*  Usage:
*
*    At startup and/or shutdown of a VFP EXE/APP
*      LOCAL m.lnFiles
*      m.lnFiles = DELETEFILES("*.tmp,*.cdx")
*
*  lParameters
*    tcFolderName (R) Folder containing files to delete.
*
*    tcDeleteFileSkeletons (R) comma-delimited list of File Skeletons 
*    such as "*.tmp,*.cdx,*.txt" or simply "*.tmp"
*                  

ASSERT ;
	VARTYPE(m.tcFolderName) = "C" ;
		AND NOT EMPTY(m.tcFolderName) ;
	MESSAGE "FolderName must be character and not empty."

ASSERT ;
	VARTYPE(m.tcDeleteFileSkeletons) = "C" ;
		AND NOT EMPTY(m.tcDeleteFileSkeletons) ;
	MESSAGE "DeleteFileSkeleton must be character and not empty."
	
m.tcFolderName = ADDBS(m.tcFolderName)
#DEFINE kcDelimiter ","
LOCAL ;
	m.lnFilesDeleted, ;
	m.lnIteration, ;
	m.lcDeleteFileSkeleton, ;
	m.lcFileName

m.lnFilesDeleted = 0

FOR m.lnIteration = 1 TO GETWORDCOUNT(m.tcDeleteFileSkeletons,kcDelimiter)
	m.lcDeleteFileSkeleton = GETWORDNUM(m.tcDeleteFileSkeletons,m.lnIteration,kcDelimiter)
	m.lcFileName = SYS(2000,m.tcFolderName + m.lcDeleteFileSkeleton)
	DO WHILE NOT EMPTY(m.lcFileName)
		TRY
			ERASE (m.tcFolderName + m.lcFileName)
			m.lnFilesDeleted = m.lnFilesDeleted + 1
		CATCH TO m.loError
			*File could not be deleted - probably is in use, so do nothing.
		ENDTRY
		m.lcFileName = SYS(2000,m.tcFolderName + m.lcDeleteFileSkeleton,1)
	ENDDO
ENDFOR m.lnIteration
RETURN m.lnFilesDeleted


Mike Yearwood
Microsoft MVP Visual FoxPro 2008, 2009
We have enough youth. We need a fountain of smart!
There may be many ways to skin a cat, but there are very few right ways to do it.

ENTIRE THREAD

Temporary Cursor Locations Posted by Sajan Jacob @ 6/29/2011 8:41:05 AM
RE: Temporary Cursor Locations Posted by Jun Tangunan @ 6/29/2011 8:50:56 AM
RE: Temporary Cursor Locations Posted by Sajan Jacob @ 6/29/2011 9:01:32 AM
RE: Temporary Cursor Locations Posted by Borislav Borissov @ 6/29/2011 9:03:50 AM
RE: Temporary Cursor Locations Posted by Sajan Jacob @ 6/29/2011 9:09:35 AM
RE: Temporary Cursor Locations Posted by Mike Yearwood @ 6/29/2011 5:11:37 PM
RE: Temporary Cursor Locations Posted by Sajan Jacob @ 6/30/2011 11:49:01 AM
RE: Temporary Cursor Locations Posted by Jun Tangunan @ 6/30/2011 12:20:29 AM
RE: Temporary Cursor Locations Posted by Mike Yearwood @ 6/30/2011 12:51:19 AM
RE: Temporary Cursor Locations Posted by Jun Tangunan @ 6/30/2011 1:14:29 AM
RE: Temporary Cursor Locations Posted by Jun Tangunan @ 6/29/2011 9:07:09 AM
RE: Temporary Cursor Locations Posted by Borislav Borissov @ 6/29/2011 8:51:42 AM