File Location and Setting Paths

XerVision

Member
Licensed User
How can I set or reset the path that I want a function to work in.
In my program I have my user load a file. I take a copy of that file and place it where my application is. I then explicitly do a filexist of the copied file. Then I explicitly retrievefile() from the copied file. However,
the retrievefile accesses the original file and not the copied file. Uggggh!!!!

Here is a piece of my code:
Sub LoadProgram
'Saves what it already has
#break# EmbedClean
Progname=GetProgram
XVPLOAD_g =1
'Load.File
#break# if FileExist(AppPath&"\"&Progname) then
LoadTables(AppPath&"\"&Progname,"prog")
End If
SaveTables
WOSetupData
End Sub

Sub GetProgram
Load.Filter = "*.xvp|*.xvp"
'DefFile_g= "datap.xvd"

if Load.Show = cCancel then
return
else
'Move the file to where the program is
FileCopy(Load.File,FileName(Load.File))
'possibly save the old .xvv
'check and see if their is an accompanying .xvd - if so load the .xvd
Return FileName(Load.File)
end if
End Sub


Sub LoadTables(EMBEDfile,fname)

ErrorLabel (errHandler)


atemp =fname&".xva.txt"
ptemp=fname&".xvv.txt"
dtemp=fname&".xvd.txt"

TheVFile= PFile_g
if FileExist (EMBEDfile) then

FileOpen(d2,EMBEDfile,cRandom)
Xemb.New1(d2,true)

'This is not the first Run and everything should be setup.
'User must setup before user can load and .XVP
FIRSTRUN_g = 0
'Unembed Files


'VISION/PROGRAM DATAFILE
'Load Up Table with Data files
Xemb.RetrieveFile(TheVFile)
if FileExist(TheVFile) then
'Clear the old vision table
RemoveVisTable
'Unencrypt files with key
DecryptFile (TheVFile,ptemp)
USERTABLEP.LoadCSV(ptemp,delim, True,True)
FileDel(ptemp)
...
 

Cableguy

Expert
Licensed User
Longtime User
If you CAN "see" the copy file then you should be able to acess it...Try to put a message box with the name of the file You are trying to retrieve...

The code you posted isn't very clear on wich part accesses the copied file....
 

RandomCoder

Well-Known Member
Licensed User
Longtime User
XerVision
Sub LoadProgram
'Saves what it already has
#break# EmbedClean
Progname=GetProgram
XVPLOAD_g =1
'Load.File
MsgBox(AppPath&"\"&Progname)
#break# if FileExist(AppPath&"\"&Progname) then
LoadTables(AppPath&"\"&Progname,"prog")
End If
SaveTables
WOSetupData
End Sub

All looks good to me, try adding the line I've inserted to check that the AppPath is still focused in the correct directory.

Regards,
RandomCoder.
 
Top