Plateforme Level Extreme
Abonnement
Profil corporatif
Produits & Services
Support
Légal
English
Copy file fails with embedded files
Message
 
À
Tous
Information générale
Forum:
Visual FoxPro
Catégorie:
Codage, syntaxe et commandes
Titre:
Copy file fails with embedded files
Divers
Thread ID:
00814381
Message ID:
00814381
Vues:
54
I have some code which works fine when I run it from a .prg or from the command window. However when I run it from a .exe it fails. I have the file I want to copy in the .exe and I want to make an actual copy of it. In one case it's a stylesheet and I want to let the user make changes. However if they stuff up all they have to do is delete it and the file will be recreated. If I load it on install then they can't recover from errors and it's important to me that the default is always available.

So, I've been mucking about and testing and my latest workaround is shown at the bottom of this post.

By using locfile() I'm able to get the path of the file but then can't use that to make the copy. I would have thought that I could just use the file name anyway as fox will do the locfile() anyway but neither approach works.

Any ideas?

Sarah

example call: this.copyfiletest("reports.css","Reports\", .t.)


lparameter tcName, tcDestPath, tlCheck
local i, lcNewPath, lcRoot, lnPathLen, lcFile

lcRoot = fullpath(curdir())
lcNewPath = lcRoot + tcDestPath
lnPathLen = len(lcNewPath )
wait window "should have a file at: " + lcNewPath + tcName

if tlCheck
for i = 1 to 10
wait window "about to locate the file"
lcFile = locfile(lcNewPath + tcName)
wait window "have the file: " + lcFile
if left(lcFile, lnPathLen) != lcNewPath
wait window "about to copy"
*//falls over on the next line
copy file (lcFile) to (lcNewPath + tcName)
wait window "copy has been done."
lcFile = locfile(lcNewPath + tcName)

if left(lcFile, lnPathLen) # lcNewPath
wait window "copy file " + tcName+ ": " + ltrim(str(i)) + " attempt. (lcFile: " + lcFile + ")"
else
wait window "successful copy of " + tcName+ " to " + lcFile
exit
endif
endif
next i
else
copy file (tcName) to (lcNewPath + tcName)
endif
return .t.
Sarah King
pcpropertymanager.com
Suivant
Répondre
Fil
Voir

Click here to load this message in the networking platform