Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. Problem in .exe copy

Problem in .exe copy

Scheduled Pinned Locked Moved C / C++ / MFC
helpquestion
17 Posts 5 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • C CPallini

    vcprog wrote:

    I am copy file data from source to destination.It is working only for .txt file

    What happens with other file types?

    vcprog wrote:

    CopyFile(FileName, cs,TRUE);

    Why don't you check the return value (and call GetLastError on failure?)? :)

    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
    [My articles]

    V Offline
    V Offline
    vcprog
    wrote on last edited by
    #4

    What happens with other file types?

    .txt,.doc is copy successfully. And other file is not copy.. Plz help me

    C 1 Reply Last reply
    0
    • V vcprog

      What happens with other file types?

      .txt,.doc is copy successfully. And other file is not copy.. Plz help me

      C Offline
      C Offline
      CPallini
      wrote on last edited by
      #5

      What about my second question (i.e. did you check CopyFile return value? Did you call GetLastError on failure?)? :)

      If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
      This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
      [My articles]

      V 1 Reply Last reply
      0
      • C CPallini

        What about my second question (i.e. did you check CopyFile return value? Did you call GetLastError on failure?)? :)

        If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
        This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
        [My articles]

        V Offline
        V Offline
        vcprog
        wrote on last edited by
        #6

        When i am useing GetLastError then i am geting Assertion fail.. File f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\appui1.cpp Line 163 Plz help me

        C 1 Reply Last reply
        0
        • V vcprog

          When i am useing GetLastError then i am geting Assertion fail.. File f:\rtm\vctools\vc7libs\ship\atlmfc\src\mfc\appui1.cpp Line 163 Plz help me

          C Offline
          C Offline
          CPallini
          wrote on last edited by
          #7

          Actually GetLastError returns a number. Please post the code wherein the error occurs and report the error exactly as it stands. :)

          If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
          This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
          [My articles]

          V 1 Reply Last reply
          0
          • C CPallini

            Actually GetLastError returns a number. Please post the code wherein the error occurs and report the error exactly as it stands. :)

            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
            [My articles]

            V Offline
            V Offline
            vcprog
            wrote on last edited by
            #8

            USES_CONVERSION;
            CString FileName; //Source pathCString
            cs; //Destination path
            CString CStrfilename=FileName;
            char* charfilename;
            charfilename=CStrfilename.GetBuffer();
            LPCTSTR lp;
            lp=CStrfilename;
            PathSkipRoot(lp);
            cs = "\\BackUp\\";
            cs += PathSkipRoot(lp);
            //CString st;
            //AfxMessageBox(cs);
            // CopyFile(st, cs,TRUE);
            DWORD dwError = GetLastError();
            CopyFile(FileName, cs,TRUE);
            AfxMessageBox(dwError);

            S C enhzflepE 3 Replies Last reply
            0
            • V vcprog

              USES_CONVERSION;
              CString FileName; //Source pathCString
              cs; //Destination path
              CString CStrfilename=FileName;
              char* charfilename;
              charfilename=CStrfilename.GetBuffer();
              LPCTSTR lp;
              lp=CStrfilename;
              PathSkipRoot(lp);
              cs = "\\BackUp\\";
              cs += PathSkipRoot(lp);
              //CString st;
              //AfxMessageBox(cs);
              // CopyFile(st, cs,TRUE);
              DWORD dwError = GetLastError();
              CopyFile(FileName, cs,TRUE);
              AfxMessageBox(dwError);

              S Offline
              S Offline
              SandipG
              wrote on last edited by
              #9

              vcprog wrote:

              DWORD dwError = GetLastError();

              You should call this after

              vcprog wrote:

              CopyFile(FileName, cs,TRUE);

              And then check error code why Copy fails?? Is it right?

              Regards, Sandip.

              1 Reply Last reply
              0
              • V vcprog

                USES_CONVERSION;
                CString FileName; //Source pathCString
                cs; //Destination path
                CString CStrfilename=FileName;
                char* charfilename;
                charfilename=CStrfilename.GetBuffer();
                LPCTSTR lp;
                lp=CStrfilename;
                PathSkipRoot(lp);
                cs = "\\BackUp\\";
                cs += PathSkipRoot(lp);
                //CString st;
                //AfxMessageBox(cs);
                // CopyFile(st, cs,TRUE);
                DWORD dwError = GetLastError();
                CopyFile(FileName, cs,TRUE);
                AfxMessageBox(dwError);

                C Offline
                C Offline
                CPallini
                wrote on last edited by
                #10

                vcprog wrote:

                // CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);

                Please replace the above sequence with the following

                if ( CopyFile(FileName, cs, TRUE) != TRUE)
                {
                DWORD dwError = GetLastError();
                CString szMsg;
                szMsg.Format("Error number %d", dwError);
                AfxMessageBox(szMsg);
                }
                else
                {
                AfxMessageBox("Success");
                }

                and post the output.

                If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
                -- Alfonso the Wise, 13th Century King of Castile.
                This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
                -- Iain Clarke
                [My articles]

                V 2 Replies Last reply
                0
                • C CPallini

                  vcprog wrote:

                  // CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);

                  Please replace the above sequence with the following

                  if ( CopyFile(FileName, cs, TRUE) != TRUE)
                  {
                  DWORD dwError = GetLastError();
                  CString szMsg;
                  szMsg.Format("Error number %d", dwError);
                  AfxMessageBox(szMsg);
                  }
                  else
                  {
                  AfxMessageBox("Success");
                  }

                  and post the output.

                  If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
                  -- Alfonso the Wise, 13th Century King of Castile.
                  This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
                  -- Iain Clarke
                  [My articles]

                  V Offline
                  V Offline
                  vcprog
                  wrote on last edited by
                  #11

                  Error no. 32 for .exe file and Error no. 3 for .txt file. But .txt file is copy file is Success. Plz help me

                  V C 2 Replies Last reply
                  0
                  • C CPallini

                    vcprog wrote:

                    // CopyFile(st, cs,TRUE); DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);

                    Please replace the above sequence with the following

                    if ( CopyFile(FileName, cs, TRUE) != TRUE)
                    {
                    DWORD dwError = GetLastError();
                    CString szMsg;
                    szMsg.Format("Error number %d", dwError);
                    AfxMessageBox(szMsg);
                    }
                    else
                    {
                    AfxMessageBox("Success");
                    }

                    and post the output.

                    If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
                    -- Alfonso the Wise, 13th Century King of Castile.
                    This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
                    -- Iain Clarke
                    [My articles]

                    V Offline
                    V Offline
                    vcprog
                    wrote on last edited by
                    #12

                    Plz help me

                    1 Reply Last reply
                    0
                    • V vcprog

                      USES_CONVERSION;
                      CString FileName; //Source pathCString
                      cs; //Destination path
                      CString CStrfilename=FileName;
                      char* charfilename;
                      charfilename=CStrfilename.GetBuffer();
                      LPCTSTR lp;
                      lp=CStrfilename;
                      PathSkipRoot(lp);
                      cs = "\\BackUp\\";
                      cs += PathSkipRoot(lp);
                      //CString st;
                      //AfxMessageBox(cs);
                      // CopyFile(st, cs,TRUE);
                      DWORD dwError = GetLastError();
                      CopyFile(FileName, cs,TRUE);
                      AfxMessageBox(dwError);

                      enhzflepE Offline
                      enhzflepE Offline
                      enhzflep
                      wrote on last edited by
                      #13

                      cpallini wrote:

                      Please post the code wherein the error occurs and report the error exactly as it stands.

                      vcprog wrote:

                      DWORD dwError = GetLastError(); CopyFile(FileName, cs,TRUE); AfxMessageBox(dwError);

                      Aye, aye, aye! As stated above, GetLastError returns an integer. You then need to use this integer IN CONJUNCTION WITH FormatMessage to get a printable text string. If you have a look here, you can see an example of use for the two functions: http://msdn.microsoft.com/en-us/library/ms680582(VS.85).aspx[^] We will "please help", so long as you will "please read".....

                      1 Reply Last reply
                      0
                      • V vcprog

                        Error no. 32 for .exe file and Error no. 3 for .txt file. But .txt file is copy file is Success. Plz help me

                        V Offline
                        V Offline
                        Vincen Wang
                        wrote on last edited by
                        #14

                        haha~ The error number is exactly the same as that we have expected. Click Tools >> error Lookup,enter the error number, then you may have the answer.

                        You know some birds are not meant to be caged, their feathers are just too bright.

                        V 1 Reply Last reply
                        0
                        • V Vincen Wang

                          haha~ The error number is exactly the same as that we have expected. Click Tools >> error Lookup,enter the error number, then you may have the answer.

                          You know some birds are not meant to be caged, their feathers are just too bright.

                          V Offline
                          V Offline
                          vcprog
                          wrote on last edited by
                          #15

                          thx's for reply.. Error is

                          The process cannot access the file because it is being used by another process.

                          Plz help me

                          V 1 Reply Last reply
                          0
                          • V vcprog

                            Error no. 32 for .exe file and Error no. 3 for .txt file. But .txt file is copy file is Success. Plz help me

                            C Offline
                            C Offline
                            CPallini
                            wrote on last edited by
                            #16

                            from WinError.h

                            //
                            // MessageId: ERROR_PATH_NOT_FOUND
                            //
                            // MessageText:
                            //
                            // The system cannot find the path specified.
                            //
                            #define ERROR_PATH_NOT_FOUND 3L

                            and

                            //
                            // MessageId: ERROR_SHARING_VIOLATION
                            //
                            // MessageText:
                            //
                            // The process cannot access the file because it is being used by another process.
                            //
                            #define ERROR_SHARING_VIOLATION 32L

                            I think they're quite explanatory. :)

                            If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler. -- Alfonso the Wise, 13th Century King of Castile.
                            This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong. -- Iain Clarke
                            [My articles]

                            1 Reply Last reply
                            0
                            • V vcprog

                              thx's for reply.. Error is

                              The process cannot access the file because it is being used by another process.

                              Plz help me

                              V Offline
                              V Offline
                              Vincen Wang
                              wrote on last edited by
                              #17

                              i find your problem is not to programe,is to use the computer.

                              You know some birds are not meant to be caged, their feathers are just too bright.

                              1 Reply Last reply
                              0
                              Reply
                              • Reply as topic
                              Log in to reply
                              • Oldest to Newest
                              • Newest to Oldest
                              • Most Votes


                              • Login

                              • Don't have an account? Register

                              • Login or register to search.
                              • First post
                                Last post
                              0
                              • Categories
                              • Recent
                              • Tags
                              • Popular
                              • World
                              • Users
                              • Groups