VFP5.0
I am trying to let the user select a file, using GETFILE, to copy to a floppy. I use PUTFILE() to allow the selection of the same OR different output filename. I am using low level file manipulation for the purpose of getting better control of the progress bar so the user doesn't sit there wondering if anything is really happening. Using FWRITE, the progress bar part works fine.
I use FILE() to determine if the file already exist on the destination drive. It is here I have the trouble. I have used the file() function many times with no trouble while working in a given directory. What I am doing different this time is trying to determine if the file exists in a different drive/directory; specifically does the file exist on the A drive floppy while working from a subdirectory on the C drive. The trouble is, if the filename exists anywhere, FILE() returns a .T. I even tried hard coding the path, IF FILE(A:\[filename]) and it always returns .T. even with a blank formatted floppy! I am using essentially the lines as found in the help file.
cFileNameIn = GETFILE('*','Read File Name','',0)
.
*Select the A drive and the same filename...
cFileOutName = PUTFILE('Write file name',cFileNameIn,cFileNameInExt)
*cFileOutName should now be something like "A:\[filename]"
.
.
IF FILE(cFileOutName) && Does file exist?
*Should fail this if floppy is blank...
gnTestFile = FOPEN(cFileOutName,12) && If so, open read/write
ELSE
gnTestFile = FCREATE(cFileOutName) && If not create it; READ/WRITE
ENDIF
It never fails the IF and returns a positive handle but of course fails to open a new file. It never gets to the FCREATE().
Now, if I CHANGE the name of the output file to something that I know does not exist anywhere, it WILL create the new file on the A drive and everything works fine.
It seems that without a name change, it remembers the original path and sticks to it no matter if I change it or not.
What am I missing here?
Thanks,
George
I am trying to let the user select a file, using GETFILE, to copy to a floppy. I use PUTFILE() to allow the selection of the same OR different output filename. I am using low level file manipulation for the purpose of getting better control of the progress bar so the user doesn't sit there wondering if anything is really happening. Using FWRITE, the progress bar part works fine.
I use FILE() to determine if the file already exist on the destination drive. It is here I have the trouble. I have used the file() function many times with no trouble while working in a given directory. What I am doing different this time is trying to determine if the file exists in a different drive/directory; specifically does the file exist on the A drive floppy while working from a subdirectory on the C drive. The trouble is, if the filename exists anywhere, FILE() returns a .T. I even tried hard coding the path, IF FILE(A:\[filename]) and it always returns .T. even with a blank formatted floppy! I am using essentially the lines as found in the help file.
cFileNameIn = GETFILE('*','Read File Name','',0)
.
*Select the A drive and the same filename...
cFileOutName = PUTFILE('Write file name',cFileNameIn,cFileNameInExt)
*cFileOutName should now be something like "A:\[filename]"
.
.
IF FILE(cFileOutName) && Does file exist?
*Should fail this if floppy is blank...
gnTestFile = FOPEN(cFileOutName,12) && If so, open read/write
ELSE
gnTestFile = FCREATE(cFileOutName) && If not create it; READ/WRITE
ENDIF
It never fails the IF and returns a positive handle but of course fails to open a new file. It never gets to the FCREATE().
Now, if I CHANGE the name of the output file to something that I know does not exist anywhere, it WILL create the new file on the A drive and everything works fine.
It seems that without a name change, it remembers the original path and sticks to it no matter if I change it or not.
What am I missing here?
Thanks,
George