|
Home > Archive > FoxPro Help and Support > April 2006 > Issue with Macro Substitution and COPY FILE
You are viewing an archived Text-only version of the thread.
To view this thread in it's original format and/or if you want to reply to
this thread please [click here]
| Author |
Issue with Macro Substitution and COPY FILE
|
|
| Ryan Gaudet 2006-03-31, 8:28 pm |
| Hi,
I wrote a small app that I'm using in conjunction with another app to update
the exe and I am having an issue passing a UNC path to the COPY FILE and
RENAME command.
Here is the code;
lcCurrentEXE = Thisform.currentexe
lcUpdatedEXE = Thisform.Updatedexe
lcNewFileName = SUBSTR(Thisform. CurrentExe,1,LEN(Thi
sform.Currentexe)-4) +
'old'
IF FILE(lcNewFileName)
DELETE FILE (lcNewFileName)
ENDIF
RENAME (lcCurrentEXE) TO (lcNewFileName)
COPY FILE (lcUpdatedEXE) TO (lcCurrentEXE)
All of the variable values contain a filename (with extension) and path and
if any of the variables contain a drive letter (ie: c:\tes.exe), the code
works however if the variable contains a UNC path (ie:
\\server1\share\tes.exe) the code fails.
I've tried using a macro substitution (ie: COPY FILE &variable) but that
doesn't work. In the debugger, the UNC path is shows correctly in the
variable window so I'm kind of stumped.
I have used UNC paths before with VFP but not with these commands and I'm
hoping there is a way to do it as I can't map a drive.
Thanks
| |
| Fred Taylor 2006-04-01, 11:28 am |
| Sounds like you may have a rights issue to your files or folders. UNC names
work just fine in VFP.
If you "hardcode" your COPY FILE command using the actual UNC names (not in
a variable), does it work?
--
Fred
Microsoft Visual FoxPro MVP
"Ryan Gaudet" < RyanGaudet@discussio
ns.microsoft.com> wrote in message
news:11C40A91-B56B-4E34-A2B1- C04689D317C6@microso
ft.com...
> Hi,
> I wrote a small app that I'm using in conjunction with another app to
> update
> the exe and I am having an issue passing a UNC path to the COPY FILE and
> RENAME command.
> Here is the code;
> lcCurrentEXE = Thisform.currentexe
> lcUpdatedEXE = Thisform.Updatedexe
> lcNewFileName = SUBSTR(Thisform. CurrentExe,1,LEN(Thi
sform.Currentexe)-4) +
> 'old'
> IF FILE(lcNewFileName)
> DELETE FILE (lcNewFileName)
> ENDIF
> RENAME (lcCurrentEXE) TO (lcNewFileName)
> COPY FILE (lcUpdatedEXE) TO (lcCurrentEXE)
>
> All of the variable values contain a filename (with extension) and path
> and
> if any of the variables contain a drive letter (ie: c:\tes.exe), the code
> works however if the variable contains a UNC path (ie:
> \\server1\share\tes.exe) the code fails.
> I've tried using a macro substitution (ie: COPY FILE &variable) but that
> doesn't work. In the debugger, the UNC path is shows correctly in the
> variable window so I'm kind of stumped.
> I have used UNC paths before with VFP but not with these commands and I'm
> hoping there is a way to do it as I can't map a drive.
> Thanks
| |
|
| it could also be a issue with spaces embedded within the folder or file
names. surround the expression in quotes.
Fred Taylor wrote:
> Sounds like you may have a rights issue to your files or folders. UNC names
> work just fine in VFP.
>
> If you "hardcode" your COPY FILE command using the actual UNC names (not in
> a variable), does it work?
>
| |
| Ryan Gaudet 2006-04-01, 1:27 pm |
| Thanks for your response Fred,
If I hardcode the UNC path, it works fine. If I use a variable (Either using
a macro substitution or variable), I get a file not found error although the
path and filename shown in the error dialog points to the exisiting file.
I tried using the Copy File command using variables from the command window
using the same file and it worked?
Any other suggestions would be appreciated.
Thanks,
Ryan
"Fred Taylor" wrote:
> Sounds like you may have a rights issue to your files or folders. UNC names
> work just fine in VFP.
>
> If you "hardcode" your COPY FILE command using the actual UNC names (not in
> a variable), does it work?
>
> --
> Fred
> Microsoft Visual FoxPro MVP
>
>
> "Ryan Gaudet" < RyanGaudet@discussio
ns.microsoft.com> wrote in message
> news:11C40A91-B56B-4E34-A2B1- C04689D317C6@microso
ft.com...
>
>
>
| |
| Ryan Gaudet 2006-04-01, 1:27 pm |
| Hi Jay B,
There are no spaces in the filename and they are enclosed in quotes.
Ryan
"Jay B" wrote:
> it could also be a issue with spaces embedded within the folder or file
> names. surround the expression in quotes.
>
>
> Fred Taylor wrote:
>
| |
| Ryan Gaudet 2006-04-01, 1:27 pm |
| I've found the problem. The variable value comes from an ini file and I had
enclosed the value in quotes however I missed one quote.
Sorry for the trouble but thanks for the responses. I've been coding in VFP
for about 8 years but haven't done any coding for about a year and am a bit
rusty....
Thanks again
Ryan
"Ryan Gaudet" wrote:
[color=darkred]
> Thanks for your response Fred,
> If I hardcode the UNC path, it works fine. If I use a variable (Either using
> a macro substitution or variable), I get a file not found error although the
> path and filename shown in the error dialog points to the exisiting file.
> I tried using the Copy File command using variables from the command window
> using the same file and it worked?
> Any other suggestions would be appreciated.
> Thanks,
> Ryan
>
> "Fred Taylor" wrote:
>
| |
| Fred Taylor 2006-04-01, 1:27 pm |
| If it works from the command window using variables, then there is no reason
it wouldn't work in code, unless the variables do not contain what you think
they do.
--
Fred
Microsoft Visual FoxPro MVP
"Ryan Gaudet" < RyanGaudet@discussio
ns.microsoft.com> wrote in message
news:0717383A-5C91-4EAA-B81A- D561C0FE7E39@microso
ft.com...[color=darkred]
> Thanks for your response Fred,
> If I hardcode the UNC path, it works fine. If I use a variable (Either
> using
> a macro substitution or variable), I get a file not found error although
> the
> path and filename shown in the error dialog points to the exisiting file.
> I tried using the Copy File command using variables from the command
> window
> using the same file and it worked?
> Any other suggestions would be appreciated.
> Thanks,
> Ryan
>
> "Fred Taylor" wrote:
>
|
|
|
|
|