* copy file (tcName) to (lcNewPath + tcName) STRTOFILE(FILETOSTR(tcName), lcNewPath + tcName)>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.
>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.