<?xml version="1.0" encoding="UTF-8"?><rss xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:atom="http://www.w3.org/2005/Atom" version="2.0"><channel><title><![CDATA[CopyFile]]></title><description><![CDATA[<p>Hallo</p>
<p>Über ein Button will eich meine Einstellungen exportieren, d.h. einfach meine Einstellungen.ini kopieren und irgendwo speichern. Hab auch hingekriegt:</p>
<p>CopyFile(quelle,ziel,true);</p>
<p>Das Problem ist es, wenn ich erneut auf den Button klicke passiert nichts, Programm öffne, schließe -&gt; funktioniert, aber wiederum nur ein Mal</p>
<p>Muss ich CopyFile() irgendwie schließen oder so???</p>
<p>Bin für jeden Tipp sehr dankbar!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/56367/copyfile</link><generator>RSS for Node</generator><lastBuildDate>Tue, 02 Jun 2026 07:58:56 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/56367.rss" rel="self" type="application/rss+xml"/><pubDate>Mon, 24 Nov 2003 20:35:26 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to CopyFile on Mon, 24 Nov 2003 20:35:26 GMT]]></title><description><![CDATA[<p>Hallo</p>
<p>Über ein Button will eich meine Einstellungen exportieren, d.h. einfach meine Einstellungen.ini kopieren und irgendwo speichern. Hab auch hingekriegt:</p>
<p>CopyFile(quelle,ziel,true);</p>
<p>Das Problem ist es, wenn ich erneut auf den Button klicke passiert nichts, Programm öffne, schließe -&gt; funktioniert, aber wiederum nur ein Mal</p>
<p>Muss ich CopyFile() irgendwie schließen oder so???</p>
<p>Bin für jeden Tipp sehr dankbar!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401622</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401622</guid><dc:creator><![CDATA[Shot]]></dc:creator><pubDate>Mon, 24 Nov 2003 20:35:26 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 07:32:51 GMT]]></title><description><![CDATA[<p>Servus,</p>
<blockquote>
<p>BOOL CopyFile(<br />
LPCTSTR lpExistingFileName,<br />
LPCTSTR lpNewFileName,<br />
BOOL bFailIfExists<br />
);</p>
<p>Parameters<br />
lpExistingFileName<br />
[in] Pointer to a null-terminated string that specifies the name of an existing file.<br />
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend &quot;\?\&quot; to the path. For more information, see Naming a File.</p>
<p>Windows Me/98/95: This string must not exceed MAX_PATH characters.</p>
<p>lpNewFileName<br />
[in] Pointer to a null-terminated string that specifies the name of the new file.<br />
In the ANSI version of this function, the name is limited to MAX_PATH characters. To extend this limit to 32,767 wide characters, call the Unicode version of the function and prepend &quot;\?\&quot; to the path. For more information, see Naming a File.</p>
<p>Windows Me/98/95: This string must not exceed MAX_PATH characters.</p>
<p>**<br />
bFailIfExists<br />
[in] If this parameter is TRUE and the new file specified by lpNewFileName already exists, the function fails. If this parameter is FALSE and the new file already exists, the function overwrites the existing file and succeeds.**</p>
</blockquote>
<p>Du musst den letzten Parameter auf False setzen damit er die bereits kopierte Datei wieder überschreibt.</p>
<p>*winke*<br />
Hellsgore</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401725</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401725</guid><dc:creator><![CDATA[Hellsgore]]></dc:creator><pubDate>Tue, 25 Nov 2003 07:32:51 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 10:07:36 GMT]]></title><description><![CDATA[<p>Morgen.</p>
<p>Danke fürs Antwort. Mein Problem liegt wo anders, habe wahrscheinlich nicht richtig beschrieben...</p>
<p>Müsste eingentlich alles richtig sein, funzt auch. Zieldatei bekommt auch jedesmal neue Name. Wenn ich das CopyFile wo anders im Programm oder selbe Funktion nochmals ausführe dann funktioniert es nicht mehr.</p>
<p>CopyFile funktioniert nur einmal pro Programmstart!!!! Das ist mein Problem, muss ich irgendwie CopyFile schliessen???</p>
<p>void CSucheSoftwareDlg::OnSpeichernFehlerprotokollTxt()<br />
{<br />
CString quelle,ziel;<br />
quelle=AktPfadFinden()+&quot;\\Data\\Fehlerprotokoll.txt&quot;;<br />
int i=0;<br />
// Zeig einen &quot;Speichern unter&quot; Dialog<br />
CFileDialog file( FALSE, //TRUE öffnen, False speichern<br />
NULL,<br />
NULL,<br />
OFN_OVERWRITEPROMPT |<br />
FN_PATHMUSTEXIST, //OFN_ENABLESIZING|OFN_OVERWRITEPROMPT,<br />
&quot;*txt|*.txt|&quot;<br />
);</p>
<p>if (file.DoModal() == IDOK)<br />
{<br />
ziel=file.GetPathName(); //Vollständige Dateipfad inkl. .ini</p>
<p>if(ziel.Find(&quot;.txt&quot;)==(-1))//auch Endung .ini eingegeben oder nur Filename???<br />
ziel+=&quot;.txt&quot;;</p>
<p>i=CopyFile((LPCTSTR)quelle,(LPCTSTR)ziel,true);<br />
}</p>
<p>if(i)<br />
MessageBox(&quot;Fehlerprotokoll wurde unter:\n&quot; + ziel+&quot;\ngespeichert.&quot;);<br />
else<br />
MessageBox(&quot;Fehlerprotokoll konnte nicht gespeichert werden.&quot;,0,48);</p>
<p>}</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401818</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401818</guid><dc:creator><![CDATA[Shot]]></dc:creator><pubDate>Tue, 25 Nov 2003 10:07:36 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 10:17:58 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>mach mal das:</p>
<pre><code class="language-cpp">if (file.DoModal() == IDOK) 
{ 
ziel=file.GetPathName(); //Vollständige Dateipfad inkl. .ini 

if(ziel.Find(&quot;.txt&quot;)==(-1))//auch Endung .ini eingegeben oder nur Filename??? 
ziel+=&quot;.txt&quot;; 

i=CopyFile((LPCTSTR)quelle,(LPCTSTR)ziel,true); 
DWORD dwError = GetLastError(); //&lt;&lt;&lt;---------------------------------
} 

if(i) 
MessageBox(&quot;Fehlerprotokoll wurde unter:\n&quot; + ziel+&quot;\ngespeichert.&quot;); 
else 
MessageBox(&quot;Fehlerprotokoll konnte nicht gespeichert werden.&quot;,0,48); 

}
</code></pre>
<p>Führe das mal zweimal aus und gucke mal was in dwError steht und geb uns das mal. Dann sieht man ja normalerweise was für ein Fehler entsteht. Einfach mal durchdebuggen.</p>
<p>*winke*<br />
Hellsgore</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401825</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401825</guid><dc:creator><![CDATA[Hellsgore]]></dc:creator><pubDate>Tue, 25 Nov 2003 10:17:58 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 10:58:15 GMT]]></title><description><![CDATA[<p>ich bekomme erst 0, dann 3...<br />
was bedeutet das?</p>
<pre><code class="language-cpp">i=CopyFile((LPCTSTR)quelle,(LPCTSTR)ziel,true);
		DWORD dwError = GetLastError(); //&lt;&lt;&lt;--------------------------------- 
		CString h;
		h.Format(&quot;%d&quot;,dwError);
		MessageBox(h);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/401852</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401852</guid><dc:creator><![CDATA[Shot]]></dc:creator><pubDate>Tue, 25 Nov 2003 10:58:15 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 11:02:28 GMT]]></title><description><![CDATA[<p>Servus,</p>
<p>wenn du solche Sachen hast kannst du immer schön mit einem GetLastError() arbeiten. Dann guckst du in der Hilfe nach unter SystemErrorCodes findest du z.B. bei GetLastError und dann steht da:</p>
<blockquote>
<p>3 The system cannot find the path specified. ERROR_PATH_NOT_FOUND</p>
</blockquote>
<p>Überprüfe mal ob bei deinem zweiten durchlauf die beiden Pfadangaben noch stimmen oder ob sie garnicht mehr vorhanden sind.</p>
<p>*winke*<br />
Hellsgore</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401856</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401856</guid><dc:creator><![CDATA[Hellsgore]]></dc:creator><pubDate>Tue, 25 Nov 2003 11:02:28 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 11:38:58 GMT]]></title><description><![CDATA[<p>Hi<br />
Danke, Danke <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f603.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--grinning_face_with_big_eyes"
      title=":D"
      alt="😃"
    /></p>
<p>Ich habs, Pfad hat nicht mehr gestimmt...</p>
<p>AktPfadFinden() funzt nicht so wie ich dachte, rufe jetzt diese Funktion nur beim Programmstart auf und speichere Ergebnis in eine Variable....</p>
<p>Danke für deine Hilfe, Hellsgore!!! <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f44d.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--thumbs_up"
      title=":+1:"
      alt="👍"
    /></p>
<pre><code class="language-cpp">CString CSucheSoftwareDlg::AktPfadFinden(void)
{
	TCHAR DirPuffer[MAX_PATH];					// Puffer für Verzeichnisname generieren
	::GetCurrentDirectory(MAX_PATH, DirPuffer);	// aktuelles Directory abfragen und speichern
	CString Path = DirPuffer;  
	return(Path);
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/401874</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401874</guid><dc:creator><![CDATA[Shot]]></dc:creator><pubDate>Tue, 25 Nov 2003 11:38:58 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 12:49:18 GMT]]></title><description><![CDATA[<p>Kein Prob<br />
aber wenn du das Verzeichnis der Exe haben möchtest kannst du auch:</p>
<pre><code class="language-cpp">//Pfad nehmen in der die Exe ausgeführt wird
		CString strPath = GetCommandLine();// Pfad + Name der Exe holen 
		int pos = strPath.ReverseFind( '\\'); // letztes '\' finden 
		strPath = strPath.Mid(1, pos-1); // Name der Exe abtrennen, so dass nur noch der Pfad übrig bleibt
</code></pre>
<p>benutzen dann steht in strPath immer der Pfad der Exe drin. Der Code ist hier aus dem Forum. Das kannst du immer aufrufen und bekommst den Aktuellen Pfad der Exe. Kannst es aber auch so lassen wie du das hast.</p>
<p>*winke*<br />
Hellsgore</p>
]]></description><link>https://www.c-plusplus.net/forum/post/401916</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401916</guid><dc:creator><![CDATA[Hellsgore]]></dc:creator><pubDate>Tue, 25 Nov 2003 12:49:18 GMT</pubDate></item><item><title><![CDATA[Reply to CopyFile on Tue, 25 Nov 2003 13:08:45 GMT]]></title><description><![CDATA[<p>Danke für den Tipp Hellsgore!</p>
<p>wider was dazugelernt <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f642.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--slightly_smiling_face"
      title=":)"
      alt="🙂"
    /></p>
]]></description><link>https://www.c-plusplus.net/forum/post/401935</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/401935</guid><dc:creator><![CDATA[Shot]]></dc:creator><pubDate>Tue, 25 Nov 2003 13:08:45 GMT</pubDate></item></channel></rss>