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