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
CODE PROJECT For Those Who Code
  • Home
  • Articles
  • FAQ
Community
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. copying file to another file..

copying file to another file..

Scheduled Pinned Locked Moved C / C++ / MFC
question
30 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.
  • M mpallavi

    Hi all I am using CFile class.. here is my code.. ........................ void CCNPhoneDlg::OnSave() {this->UpdateData(); CFile source; CFile dest; char strFilter[] = { "Log Files (*.log)|*.log|" }; CFileDialog FileDlg(FALSE, ".log", NULL, 0, strFilter); if( source.Open("LogFile.log", CFile::modeRead | CFile::shareDenyWrite ) == FALSE ) return; if( FileDlg.DoModal() == IDOK ) { if( dest.Open(FileDlg.GetPathName(),CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)==FALSE) return; CString fl; fl=FileDlg.GetPathName(); char c[1000]; int len; len=strlen("LogFile.txt"); do { source.Read(c,1000); dest.Write(c,len); } while (!EOF); source.Close(); dest.Close(); } } .................. But file is not getting created.. whats wrong with the code..? pallavi

    N Offline
    N Offline
    Nilesh K
    wrote on last edited by
    #6

    mpallavi wrote: But file is not getting created.. whats wrong with the code..? I was able to execute and save file with it, Your code is working fine!

    - Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw

    M 1 Reply Last reply
    0
    • N Nilesh K

      mpallavi wrote: But file is not getting created.. whats wrong with the code..? I was able to execute and save file with it, Your code is working fine!

      - Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw

      M Offline
      M Offline
      mpallavi
      wrote on last edited by
      #7

      hi Nilesh.. yupp .. the code is working .. i was checking in a wrong dir.. :laugh: but all the contents are not getting copied.. is your file getting copied properly? regards pallavi

      N 1 Reply Last reply
      0
      • M mpallavi

        hi Nilesh.. yupp .. the code is working .. i was checking in a wrong dir.. :laugh: but all the contents are not getting copied.. is your file getting copied properly? regards pallavi

        N Offline
        N Offline
        Nilesh K
        wrote on last edited by
        #8

        I've corrected the code, try this out.. CFile source; CFile dest; char strFilter[] = { "Log Files (*.log)|*.log|" }; CFileDialog FileDlg(FALSE, ".log", NULL, 0, strFilter); if( source.Open("LogFile.log", CFile::modeRead | CFile::shareDenyWrite ) == FALSE ) return false; if( FileDlg.DoModal() == IDOK ) { if( dest.Open(FileDlg.GetPathName(),CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)==FALSE) return false; CString fl; fl=FileDlg.GetPathName(); char c[1000]; int ncount = 0; do { memset(c,0,1000); ncount = source.Read(c,1000); if(ncount > 0) dest.Write(c,ncount); } while(ncount>0); source.Close(); dest.Close(); }

        - Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw

        M 1 Reply Last reply
        0
        • N Nilesh K

          I've corrected the code, try this out.. CFile source; CFile dest; char strFilter[] = { "Log Files (*.log)|*.log|" }; CFileDialog FileDlg(FALSE, ".log", NULL, 0, strFilter); if( source.Open("LogFile.log", CFile::modeRead | CFile::shareDenyWrite ) == FALSE ) return false; if( FileDlg.DoModal() == IDOK ) { if( dest.Open(FileDlg.GetPathName(),CFile::modeCreate | CFile::modeWrite | CFile::modeNoTruncate)==FALSE) return false; CString fl; fl=FileDlg.GetPathName(); char c[1000]; int ncount = 0; do { memset(c,0,1000); ncount = source.Read(c,1000); if(ncount > 0) dest.Write(c,ncount); } while(ncount>0); source.Close(); dest.Close(); }

          - Nilesh "Reading made Don Quixote a gentleman. Believing what he read made him mad" -George Bernard Shaw

          M Offline
          M Offline
          mpallavi
          wrote on last edited by
          #9

          Thank you so much dear.. its working fine now.. regards pallavi

          1 Reply Last reply
          0
          • T ThatsAlok

            is [CopyFile] help

            "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

            cheers, Alok Gupta

            B Offline
            B Offline
            Bob Stanneveld
            wrote on last edited by
            #10

            You were late 5 minutes! ;P Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

            M T 2 Replies Last reply
            0
            • B Bob Stanneveld

              You were late 5 minutes! ;P Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

              M Offline
              M Offline
              mpallavi
              wrote on last edited by
              #11

              Hello Bob.. Did you post your article which was supposed to be on heap manager.. regards pallavi

              T B 2 Replies Last reply
              0
              • B Bob Stanneveld

                You were late 5 minutes! ;P Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                T Offline
                T Offline
                ThatsAlok
                wrote on last edited by
                #12

                Bob Stanneveld wrote: You were late 5 minutes! Yeah, Typing with NOSE is very Difficult :), Now i have to ask Mr. Cedric to relieve me from DUTY :laugh:

                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                cheers, Alok Gupta

                M C 2 Replies Last reply
                0
                • M mpallavi

                  Hello Bob.. Did you post your article which was supposed to be on heap manager.. regards pallavi

                  T Offline
                  T Offline
                  ThatsAlok
                  wrote on last edited by
                  #13

                  mpallavi wrote: Did you post your article which was supposed to be on heap manager.. I am Also Waiting for SAME, BOB Respond :)

                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                  cheers, Alok Gupta

                  B 1 Reply Last reply
                  0
                  • M mpallavi

                    Hello Bob.. Did you post your article which was supposed to be on heap manager.. regards pallavi

                    B Offline
                    B Offline
                    Bob Stanneveld
                    wrote on last edited by
                    #14

                    Not yet, I'm almost finished with the design. I'll post the article on the design after it is final (after some coding and no more major changes should be made). Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                    M 1 Reply Last reply
                    0
                    • T ThatsAlok

                      mpallavi wrote: Did you post your article which was supposed to be on heap manager.. I am Also Waiting for SAME, BOB Respond :)

                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                      cheers, Alok Gupta

                      B Offline
                      B Offline
                      Bob Stanneveld
                      wrote on last edited by
                      #15

                      Hello, It's not the easiest thing to write. Besides that, I have little time on my hands, which I have to spend wisely. I'm not going to flunk some classes in school because I want to write that component... I'll try my best to finish it soon, but I canno't promise an exact date any time soon... Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                      T 1 Reply Last reply
                      0
                      • T ThatsAlok

                        Bob Stanneveld wrote: You were late 5 minutes! Yeah, Typing with NOSE is very Difficult :), Now i have to ask Mr. Cedric to relieve me from DUTY :laugh:

                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                        cheers, Alok Gupta

                        M Offline
                        M Offline
                        mpallavi
                        wrote on last edited by
                        #16

                        ThatsAlok wrote: Typing with NOSE is very Difficult Hi Alok.. You neck doesn't pain?.. I mean.. it must be really tiresome...:laugh: regards pal

                        T 1 Reply Last reply
                        0
                        • B Bob Stanneveld

                          Not yet, I'm almost finished with the design. I'll post the article on the design after it is final (after some coding and no more major changes should be made). Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                          M Offline
                          M Offline
                          mpallavi
                          wrote on last edited by
                          #17

                          Hey.. Wish you all the best!..:) regards pallavi

                          B 1 Reply Last reply
                          0
                          • M mpallavi

                            Hey.. Wish you all the best!..:) regards pallavi

                            B Offline
                            B Offline
                            Bob Stanneveld
                            wrote on last edited by
                            #18

                            Thanks :-D Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                            1 Reply Last reply
                            0
                            • B Bob Stanneveld

                              Hello, It's not the easiest thing to write. Besides that, I have little time on my hands, which I have to spend wisely. I'm not going to flunk some classes in school because I want to write that component... I'll try my best to finish it soon, but I canno't promise an exact date any time soon... Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                              T Offline
                              T Offline
                              ThatsAlok
                              wrote on last edited by
                              #19

                              Bob Stanneveld wrote: It's not the easiest thing to write. I know, thats why i am waiting for it. Bob Stanneveld wrote: I'll try my best to finish it soon Best of luck for that :)

                              "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                              cheers, Alok Gupta

                              B 1 Reply Last reply
                              0
                              • M mpallavi

                                ThatsAlok wrote: Typing with NOSE is very Difficult Hi Alok.. You neck doesn't pain?.. I mean.. it must be really tiresome...:laugh: regards pal

                                T Offline
                                T Offline
                                ThatsAlok
                                wrote on last edited by
                                #20

                                mpallavi wrote: You neck doesn't pain?.. I mean.. it must be really tiresome... What to do then :)

                                "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                cheers, Alok Gupta

                                M 1 Reply Last reply
                                0
                                • T ThatsAlok

                                  Bob Stanneveld wrote: It's not the easiest thing to write. I know, thats why i am waiting for it. Bob Stanneveld wrote: I'll try my best to finish it soon Best of luck for that :)

                                  "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                  cheers, Alok Gupta

                                  B Offline
                                  B Offline
                                  Bob Stanneveld
                                  wrote on last edited by
                                  #21

                                  ThatsAlok wrote: Best of luck for that Thanks :-D Behind every greak black man...             ... is the police. - Conspiracy brother Blog[^]

                                  1 Reply Last reply
                                  0
                                  • T ThatsAlok

                                    Bob Stanneveld wrote: You were late 5 minutes! Yeah, Typing with NOSE is very Difficult :), Now i have to ask Mr. Cedric to relieve me from DUTY :laugh:

                                    "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                    cheers, Alok Gupta

                                    C Offline
                                    C Offline
                                    Cedric Moonen
                                    wrote on last edited by
                                    #22

                                    I didn't know I had so much 'control' over you ;P. BTW, remove the Mr., I', not that old ;)

                                    T 1 Reply Last reply
                                    0
                                    • T ThatsAlok

                                      mpallavi wrote: You neck doesn't pain?.. I mean.. it must be really tiresome... What to do then :)

                                      "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                      cheers, Alok Gupta

                                      M Offline
                                      M Offline
                                      mpallavi
                                      wrote on last edited by
                                      #23

                                      ha ha ha.. :laugh: Byt the way.. whats your typing speed? ..pal

                                      T 1 Reply Last reply
                                      0
                                      • C Cedric Moonen

                                        I didn't know I had so much 'control' over you ;P. BTW, remove the Mr., I', not that old ;)

                                        T Offline
                                        T Offline
                                        ThatsAlok
                                        wrote on last edited by
                                        #24

                                        cedric moonen wrote: I didn't know I had so much 'control' over you Not That Much :) cedric moonen wrote: remove the Mr., I', not that old Yeah, Cedric :)

                                        "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                        cheers, Alok Gupta

                                        1 Reply Last reply
                                        0
                                        • M mpallavi

                                          ha ha ha.. :laugh: Byt the way.. whats your typing speed? ..pal

                                          T Offline
                                          T Offline
                                          ThatsAlok
                                          wrote on last edited by
                                          #25

                                          mpallavi wrote: Byt the way.. whats your typing speed? :) BY Hand : Dunno, By nose : 10 letter/Min :)

                                          "Opinions are neither right nor wrong. I cannot change your opinion. I can, however, change what influences your opinion." - David Crow

                                          cheers, Alok Gupta

                                          M 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