Avatar of Dee
Dee
Flag for United States of America asked on

VF5 Getting "File does not exist"

I am getting “File does not exist” when they definitely do exist.  I have tested this endlessly.
I am testing an app that has a list of Foxpro programs in a list box.  The user selects a a program and clicks the “Run” button.
All the test programs in the list are in the same directory.  It works(ed) for one program and not the others.
To verify the validity of the path and filename:
1)      I duplicated the file names (and path) in the list that won't work, with the same file name as the one does works.  Copy and pasted.  I still get "File does not exist".  I pasted back it back over to this same one that was working – it no longer works.

     2) Programmitically wrote the location and filename to a text box before the program tries to run it.  After getting "File Does Not Exist", I  copied and pasted the text box contents into file explorer.  It opens, every time.

   3) I removed the following from my code that I thought was triggering the "file does not exist" error:
            if empty(sys(2000,lcFilePath)) then
                lcMsg = lcFilePath + " does not exist"
                Messagebox (lcMsg)
               return
         endif

         The error still occurs.   So It is not my code that triggers "File does not exist".

    4)  I added back the above IF block with an added ELSE statement:
                  if empty(sys(2000,lcFilePath)) then
                      lcMsg = lcFilePath + " does not exist **** !!!"
                    Messagebox (lcMsg)
                  return
           else
               messagebox ("exists")
          endif

          This triggers "exists"! ….  followed by Foxpro generated message "File does not exist".  
   
    5)  I created a text file and entered the filename and location in the Foxpro table with my programs to determine if is just a problem with the prg files.  When I selected the text file in list box  and clicked the RUN button, instead of getting a file type error I was expecting, I get my "exists" message followed by Foxpro's "File does not exist" message.

         It was the Foxpro "File does not exist"  message all the time - not mine.  It never hits mine when a file really does not exist.
>>>>>>>>>>
lcFilePath = alltrim(thisform.lstProcs.List[lcIndex, 2])       

lcProcName = alltrim(thisform.lstProcs.List[lcIndex, 1]
lcFilePath = lcFilePath + “\” + lcFilePath
 do &lcFilePath with &lcParams

I have also tried using the literal file path and name:
        Do “TheFilepath” + “\” to “ProcName.prg”
         Same.   “file does not exist”
FoxPro

Avatar of undefined
Last Comment
Pavel Celba

8/22/2022 - Mon
Bill Prew

I'm not a VFP expert, but wanted to check one thing.  Any chance that the files / paths that are giving the error have spaces (or other "special" characters) in their name.  VFP is a fairly old platform, and may not handle spaces in pathnames as well as it needs to.  I think there are ways to work around it, but wanted to ask the question first.


»bp
Bernard Savonet

Have you checked the access rights?
is the missing file a data file, or a run file (binary or shell)?
ASKER CERTIFIED SOLUTION
Pavel Celba

THIS SOLUTION ONLY AVAILABLE TO MEMBERS.
View this solution by signing up for a free trial.
Members can start a 7-Day free trial and enjoy unlimited access to the platform.
See Pricing Options
Start Free Trial
GET A PERSONALIZED SOLUTION
Ask your own question & get feedback from real experts
Find out why thousands trust the EE community with their toughest problems.
Pavel Celba

BTW, your testing code is not correct. See the comments below
lcFilePath = alltrim(thisform.lstProcs.List[lcIndex, 2])       

lcProcName = alltrim(thisform.lstProcs.List[lcIndex, 1]
lcFilePath = lcFilePath + “\” + lcFilePath    &&  WHY is the lcFilePath twice here?
 do &lcFilePath with &lcParams      && NOTE: Don't use &lcFilePath  when the path or filename contains spaces

I have also tried using the literal file path and name:
        Do “TheFilepath” + “\” to “ProcName.prg”     && This calls the following file:  TheFilepath\ProcName.prg   I would guess it does not exist
         Same.   “file does not exist” 

Open in new window

Your help has saved me hundreds of hours of internet surfing.
fblack61
Dee

ASKER
celba, that was a typo in my post only,  "Thefilepath"statement ... not in my code.

Regardless, I have punished myself once again with my daily dose of stupid.

My code below never triggered the “not exist” message, because, I was puting the correct path and file name in the lcFilePath variable.

> >   lcFilePath = alltrim(alltrim(lcFilePath) + "\" + alltrim(lcProcName))
        if empty(sys(2000,lcFilePath)) then
           lcMsg = lcFilePath + " does not exist ***"
          return
        endif
*********************
I overlooked that pcelba, you used a different variable name that only contained the program name - not the file path in the code you supplied me with to get my array working..  It worked as long as the called program was in the same file path as the app.

Compounding stupid with stupid,  it was working on the one program that I did have in the same file path - before I moved it! A fact that I had forgot!

celba's code:

DIMENSION laParms[1]
LOCAL lcParame, lcProgram

> > lcProgram = lcProcName < <

SELECT varpass FROM prodprocs WHERE procname = lcProgram INTO ARRAY laParms

> > if empty(sys(2000,lcProgram)) then  < <
       lcMsg = lcFilePath + " does not exist *"
      Messagebox (lcMsg)
      return
 endif
It seems I just needed moral support … thanks for obliging! lol
Pavel Celba

I am glad it works now. We are here to provide moral support :-)