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. Please Help Me! - CopyFile Null terminated String

Please Help Me! - CopyFile Null terminated String

Scheduled Pinned Locked Moved C / C++ / MFC
questionc++help
5 Posts 3 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.
  • L Offline
    L Offline
    Lucky the code machine
    wrote on last edited by
    #1

    Hi, I am very new to C++ & have again come unstuck! I am trying to copy a file from a file selected from an open file dialog to a fixed location & name. The from (open dialog etc) works fine but the destination part dose not: CopyFile(m_File_In, "c:\\osc_out\\logo.*", FALSE); I guess this is becouse my destination is not 'null terminated'? I still get problems if i try: CString m_File_Out; m_File_Out="c:\\osc_out\\logo.*"; CopyFile(m_File_In, m_File_Out, FALSE); If this is becouse it is not null terminated how do i do that? Thanx An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky

    P PJ ArendsP 2 Replies Last reply
    0
    • L Lucky the code machine

      Hi, I am very new to C++ & have again come unstuck! I am trying to copy a file from a file selected from an open file dialog to a fixed location & name. The from (open dialog etc) works fine but the destination part dose not: CopyFile(m_File_In, "c:\\osc_out\\logo.*", FALSE); I guess this is becouse my destination is not 'null terminated'? I still get problems if i try: CString m_File_Out; m_File_Out="c:\\osc_out\\logo.*"; CopyFile(m_File_In, m_File_Out, FALSE); If this is becouse it is not null terminated how do i do that? Thanx An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky

      P Offline
      P Offline
      Paul M Watt
      wrote on last edited by
      #2

      You can only copy one file at a time. Wild card characters are not valied (*). declaring a string in quotes "", the compiler automatically NULL terminates it for you. Besides you are using a CString so that would NULL terminate it as well. You will need to change: m_File_Out="c:\\osc_out\\logo.*"; To something else like: m_File_Out="c:\\osc_out\\logo.bmp"; Or whatever file type it is because the asterisk (*) is not a legal character to use in a file name.


      Build a man a fire, and he will be warm for a day
      Light a man on fire, and he will be warm for the rest of his life!

      L 1 Reply Last reply
      0
      • L Lucky the code machine

        Hi, I am very new to C++ & have again come unstuck! I am trying to copy a file from a file selected from an open file dialog to a fixed location & name. The from (open dialog etc) works fine but the destination part dose not: CopyFile(m_File_In, "c:\\osc_out\\logo.*", FALSE); I guess this is becouse my destination is not 'null terminated'? I still get problems if i try: CString m_File_Out; m_File_Out="c:\\osc_out\\logo.*"; CopyFile(m_File_In, m_File_Out, FALSE); If this is becouse it is not null terminated how do i do that? Thanx An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky

        PJ ArendsP Offline
        PJ ArendsP Offline
        PJ Arends
        wrote on last edited by
        #3

        To expand on what kilowatt said, you can use the splitpath() function to get the file extension from m_File_In. HTH --- CPUA 0x5041 Sonork 100.11743 Chicken Little If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?

        Within you lies the power for good; Use it!

        L 1 Reply Last reply
        0
        • PJ ArendsP PJ Arends

          To expand on what kilowatt said, you can use the splitpath() function to get the file extension from m_File_In. HTH --- CPUA 0x5041 Sonork 100.11743 Chicken Little If a man is standing in the middle of the forest speaking and there is no woman around to hear him...is he still wrong?

          L Offline
          L Offline
          Lucky the code machine
          wrote on last edited by
          #4

          Thank you v.much, thats the answer i was lookin for. I will try that. Thanx again, Lucky An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky

          1 Reply Last reply
          0
          • P Paul M Watt

            You can only copy one file at a time. Wild card characters are not valied (*). declaring a string in quotes "", the compiler automatically NULL terminates it for you. Besides you are using a CString so that would NULL terminate it as well. You will need to change: m_File_Out="c:\\osc_out\\logo.*"; To something else like: m_File_Out="c:\\osc_out\\logo.bmp"; Or whatever file type it is because the asterisk (*) is not a legal character to use in a file name.


            Build a man a fire, and he will be warm for a day
            Light a man on fire, and he will be warm for the rest of his life!

            L Offline
            L Offline
            Lucky the code machine
            wrote on last edited by
            #5

            Thank you v.much. I will try that. Thanx again, Lucky An Expert is somone who has previously made ALL the Mistakes, I dream of this day. - Lucky

            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