Link to home
Start Free TrialLog in
Avatar of formadmirer
formadmirerFlag for United States of America

asked on

VFP9 File Exists?

Is there something that would make VFP report that a file exists when it does not?

I was attempting to use:

lcNoImage = (pcGraphicsDir + "no_image.jpg")
lcFileToCheck = (pcProductImages + "no_image.jpg")
IF !FILE(lcFileToCheck)
	IF FILE(lcNoImage)
		COPY FILE (lcNoImage) TO (lcFileToCheck)
	ENDIF
ENDIF

Open in new window

However, even though the file to check does not exist, and the no_image file does, the file was not copied.

I replaced ! with NOT and got the same results.

So I added wait statements and reversed the logic:

lcNoImage = (pcGraphicsDir + "no_image.jpg")
lcFileToCheck = ((pcProductImages) + "no_image.jpg")
IF FILE(lcFileToCheck)
	WAIT WINDOW "ftc exists " + lcFileToCheck && do nothing
ELSE
	WAIT WINDOW "ftc not exist " + lcFileToCheck
	IF FILE(lcNoImage)
		WAIT WINDOW "no_image exists " + lcNoImage
		COPY FILE (lcNoImage) TO (lcFileToCheck)
	ENDIF
ENDIF

Open in new window

I get the wait window that says "ftc exists". Of course the file is not copied either.

The file to check absolutely does not exist at that path - the echoed lcFileToCheck path does show the correct path where VFP is saying the file exists, but it does not.

Once again, I'm stumped.
ASKER CERTIFIED SOLUTION
Avatar of Olaf Doschke
Olaf Doschke
Flag of Germany image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
>So check files included in the project and remove unwanted .JPG files and don't recompile before APP build.

If you want to prevent file inclusion, my recommendation rather would be, to keep the file listed in project manager and just change it to exclude from compilation.

Anyway ADIR() will not look for the JPG inside the EXE, even if it's included.

Bye, Olaf.
Yes, the file exclusion is better in this case. And as I see your first answer it is faster and better then mine... :-)
Well you had the same solution, pavel, I was just giving more concrete úsage of ADIR. Even more concrete in that case, lcFullpathWithFilename would be lcFileToCheck, formadmirer.

And this time I was getting a mail alert about the new question and heard it coming in live via my tablet.

Bye, Olaf.
Avatar of formadmirer

ASKER

Thanks guys. ADIR did the trick nicely.

I was not aware that FILE would return T in such instances, just because the filename was included in the exe build.

'IF FILE()' is used extensively throughout the program I work on.

Perhaps I might need to do some replacements.