Level Extreme platform
Subscription
Corporate profile
Products & Services
Support
Legal
Français
FCLOSE and DELETE FILE so close together problem
Message
General information
Forum:
Visual FoxPro
Category:
Coding, syntax & commands
Environment versions
Visual FoxPro:
VFP 8 SP1
OS:
Windows XP SP2
Network:
Windows 2003 Server
Database:
Visual FoxPro
Application:
Desktop
Miscellaneous
Thread ID:
01545986
Message ID:
01545991
Views:
62
>Hi Gang!
>
>Problem here....
>
>I wrote this code, and our demo people are setting it up on a Window 7 64 bit PC.....
>
>This code is run every 5 minutes from a timer.
>
>It's purpose is to go out to a webservice and retrieve a text file of records to be processed locally. Worked fine here in 32 and 64 bit on OUR PCs the past 2 days..... but when the demo guys set things up, it was not exactly like our setups.... they had some permission problems on some of the folders......
>
>When the code ran today on the demo PC, during lunch.... and the tester came back... he found a
>"File Access is Denied c:\temp\ivrfill.txt"
>
>Check how it is deleted below....
>
>
>IF FILE('c:\temp\IVRFILL.TXT')
>		lnHandle = FOPEN('c:\temp\IVRFILL.TXT')
>		IF lnHandle > 0		&& Successful opening of a file....
>* Seek to end of file to determine number of bytes in the file.
>			nSize =  FSEEK(lnHandle, 0, 2)     && Move pointer to EOF
>			IF nSize <= 0
>* If file is empty, display an error message.
>				WAIT WINDOW "This file is empty!" NOWAIT
>			ELSE
>* If file is not empty, store the file's contents in memory
>* and display the text in the main Visual FoxPro window.
>				= FSEEK(lnHandle, 0, 0)      && Move pointer to BOF
>				IF nSize > 0
>					DO WHILE NOT FEOF(lnHandle)
>						lcStringSegment = FGETS(lnHandle)
>						THIS.PARENT.m_ProcessIVRstringtotable(lcStringSegment)
>					ENDDO
>				ENDIF
>			ENDIF
>*Get rid of the file, now that we are done with it....
>			FCLOSE(lnHandle)
>			DELETE FILE c:\temp\IVRFILL.TXT
>		ENDIF
>
>
>It normally worked fine here on both 32 and 64 bit PCs...... so............. is there a problem with the FCLOSE running before the DELETE FILE so quickly.... should I put a short time delay there so the file is sure to be closed by the time the DELETE FILE is called?

If the file is not too big, you can use filetostr, then alines and process each line.
If it's not broken, fix it until it is.


My Blog
Previous
Reply
Map
View

Click here to load this message in the networking platform