1. You are viewing our forum as a guest. For full access please Register. WindowsBBS.com is completely free, paid for by advertisers and donations.

Resolved VFP cannot copy files to Windows Special Folders

Discussion in 'Other PC Software' started by bob15, 2010/08/16.

  1. 2010/08/16
    bob15

    bob15 Inactive Thread Starter

    Joined:
    2010/08/16
    Messages:
    5
    Likes Received:
    0
    Hello,
    Who knows how to use VFP to copy a file to a Windows Special Folder?
    For example:
    COPY FILE C:\IMAGE1.JPG TO C:\IMAGE2.JPG (it works)
    COPY FILE C:\IMAGE1.JPG TO C:\DOCUMENTS AND SETTINGS\IMAGE2.JPG (it desn't work)
    COPY FILE( "C:\IMAGE1.JPG ") TO C:\IMAGE2.JPG (it works)
    COPY FILE( "C:\IMAGE1.JPG ") TO C:\DOCUMENTS AND SETTINGS\IMAGE2.JPG (it desn't work)

    bob15
     
  2. 2010/08/16
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,076
    Likes Received:
    178
    There is nothing magical about Windows Special folders. If you have read/write access, you can do whatever you want to do with them. It seems the user who is running the program does not have read/write access to C:\Documents and Settings folder. The proper way would be to copy the files to C:\Documents and Settings/user_name folder, where user_name is the name of the user who is logged in.
     

  3. to hide this advert.

  4. 2010/08/16
    bob15

    bob15 Inactive Thread Starter

    Joined:
    2010/08/16
    Messages:
    5
    Likes Received:
    0
    Thank you for your opinion.
    Bit it seems not a good idea to solve this problem.:D
     
  5. 2010/08/17
    Arie

    Arie Administrator Administrator Staff

    Joined:
    2001/12/27
    Messages:
    15,174
    Likes Received:
    412
    It is the solution to th problem. You'll need the correct access to the folders (directories) you want to copy these files too.
     
    Arie,
    #4
  6. 2010/08/17
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,076
    Likes Received:
    178
    Sorry, read C:\Documents and Settings\user_name instead of C:\Documents and Settings/user_name. The last slash is in Linux notation & not as per Windows.
     
  7. 2010/08/17
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,076
    Likes Received:
    178
    bob15, the surest way to be able to run program for any user is to assume nothing about that user.

    You don't know before hand his name,user type etc. Its better either to create directories which your program is going to use & assign proper access rights for the users or use Windows variables to access the common directories like temp etc.

    Never ever assume that your user would be running in Administrator mode with read/write access to all the directories if you are at all going to use NTFS partitions.
     
  8. 2010/08/17
    bob15

    bob15 Inactive Thread Starter

    Joined:
    2010/08/16
    Messages:
    5
    Likes Received:
    0
    I don't understand what is VFP's "correct access"

    I have tried following command:

    targetdir=getdir()
    ? targetdir
    C:\DOCUMENTS AND SETTINGS\OWNER\MY DOCUMENTS\MY PICTURES\

    copy file c:\image1.jpg to &targetdir

    and I got VFP error message: Command contains unrecognized phrase/keyword.
     
  9. 2010/08/17
    PeteC

    PeteC SuperGeek Staff

    Joined:
    2002/05/10
    Messages:
    28,896
    Likes Received:
    389
    Curious - what is VFP - Visual FoxPro??
     
  10. 2010/08/17
    bob15

    bob15 Inactive Thread Starter

    Joined:
    2010/08/16
    Messages:
    5
    Likes Received:
    0
    Yes. MS Visual FoxPro.:)
     
  11. 2010/08/17
    rsinfo

    rsinfo SuperGeek Alumni

    Joined:
    2005/12/25
    Messages:
    4,076
    Likes Received:
    178
    VFP is correct :rolleyes:

    Copy command expects a filename as target & not a directory [refer to VFP help where the syntax is COPY FILE FileName1 TO FileName2.] Plus your directory folder contains spaces which complicate the matter further.

    Try this :

    targetdir=getdir()
    targetdir = targetdir + "image1.jpg " && Add the target file name
    targetdir = "' " + targetdir + "' " && Add ' so that the complete path is treated as one string
    copy file c:\image1.jpg to &targetdir

    It should work now.
     
  12. 2010/08/17
    PeteC

    PeteC SuperGeek Staff

    Joined:
    2002/05/10
    Messages:
    28,896
    Likes Received:
    389
    Thanks for the enlightenment :)
     
  13. 2010/08/17
    bob15

    bob15 Inactive Thread Starter

    Joined:
    2010/08/16
    Messages:
    5
    Likes Received:
    0
    Thanks a lot! It works by adding "' ".
     
  14. 2010/08/17
    PeteC

    PeteC SuperGeek Staff

    Joined:
    2002/05/10
    Messages:
    28,896
    Likes Received:
    389
    Please mark this thread as 'Resolved', see .....
     

Share This Page

  1. This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
    By continuing to use this site, you are consenting to our use of cookies.