CodeGuru Home VC++ / MFC / C++ .NET / C# Visual Basic VB Forums Developer.com
Results 1 to 6 of 6
  1. #1
    Join Date
    Aug 2003
    Posts
    3

    Copy a file from a remote computer

    Hi Gurus!

    Please help me for this problem.
    I want to copy a file (C:\sharedir\sample.txt) from a remote computer (online).
    IP : aaa.bbb.ccc.ddd
    Computer name : pcname

    I used this command of API in MFC


    BOOL bCopyOK=::CopyFile("\\\\aaa.bbb.ccc.ddd\\c\\sharedir\\sample.txt","C:\\sample.txt",FALSE);

    or

    BOOL bCopyOK=::CopyFile("\\\\pcname\\c\\sharedir\\sample.txt","C:\\sample.txt",FALSE);


    but I can not copy this file.
    What wrong? Please help me! Thankssssss!

    I can access that sharedir .
    Last edited by never_finalboss; August 16th, 2003 at 03:00 AM.

  2. #2
    Join Date
    Apr 2003
    Posts
    1,755

    Smile

    I don't know a copy API that copies a file. Try CopyFile API instead. Also, make sure that you can access the share in the remote PC.

    Hope it will help you

  3. #3
    Join Date
    Aug 2003
    Posts
    3
    Thank to rxbagain, sorry about that problem, I editted it. Thank again!

  4. #4
    Join Date
    Apr 2003
    Posts
    1,755

    Smile

    Is the drice c shared too? If only the sharedir is shared in the remote pc, remove the "\\c" in the filename. Use the filename with the hierachy as you see with the network browser.

    "\\\\pcname\\sharedir\\sample.txt".

    Hope it will help you

  5. #5
    Join Date
    Aug 2003
    Posts
    3
    The driver C is shared too, I try copy this file using Dos Prompt like this:



    C:\copy\\aaa.bbb.ccc.ddd\\c\\sharedir\\sample.txt c:\



    This command is success, but when I can not use MFC to copy that file. Please help me

  6. #6
    Join Date
    May 2000
    Location
    KY, USA
    Posts
    18,652
    Well...as usual...check the error code. If 'CopyFile()' fails, you can get the error code by a call to 'GetLastError()'...

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  





Click Here to Expand Forum to Full Width

Featured