<?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[Probleme mit MoveFile]]></title><description><![CDATA[<p>Hallo,<br />
Ich habe ein Problem mit MoveFile:<br />
Ich habe zu meinem Programm ein automatisches Update gemacht. Die neuen Dateien werden unter &quot;Dateiname.update&quot; gespeichert. Die StringList &quot;Updates&quot; enthält die Namen der *.update Dateien mit vollem Pfad. Jetzt wollte ich als erstes die Dateien, die bereits vorhanden sind umbenennen zu &quot;Dateiname.old&quot; und dann die *.update-Dateien Die Dateiendung nach &quot;&quot; (leer) umbenennen. Der Code wurde sehr lang und umständlich, aber es lässt sich bis jetzt ausführen. Aber dann kommt der Fehler:<br />
&quot;Im Projekt... trat ein Fehler mit folgender Meldung auf: 'Zugriffsverletzung bei 0x0040f60'. Prozess angehalten. Mit Einzelne Anweisung oder Start fortsetzen.&quot;<br />
Wie könnte ich den Code besser schreiben?<br />
Hier der Code:</p>
<pre><code class="language-cpp">for(int i=0; i &lt; Updates-&gt;Count; i++)
  {
   //chars zur Erleichterung:
   LMDLabel5-&gt;Caption=&quot;Datei &quot;+AnsiString(i)+&quot; wird geupdatet&quot;;
   AnsiString Hauptpfad = ExtractFilePath(Application-&gt;ExeName);
   char *HauptpfadCh;
   HauptpfadCh = Hauptpfad.c_str();
   AnsiString UpdateFile = ChangeFileExt(Updates-&gt;Strings[i],&quot;&quot;);
   char *UpdateFileCh;
   UpdateFileCh = UpdateFile.c_str();
   AnsiString UpdateFile2 = Hauptpfad+UpdateFile;
   char *UpdateFile2Ch;
   UpdateFile2Ch = UpdateFile2.c_str();
   AnsiString UpdateFileOld = UpdateFile+&quot;.old&quot;;
   char *UpdateFileOldCh;
   UpdateFileOldCh = UpdateFileOld.c_str();
   AnsiString HauptpfadFile = Hauptpfad+Updates-&gt;Strings[i];
   char *HauptpfadFileCh;
   HauptpfadFileCh = HauptpfadFile.c_str();
   //eigentliche Dateioperation:
   if(FileExists(Updates-&gt;Strings[i]))
    {
     MoveFile(UpdateFile2Ch,UpdateFileOldCh);
    }
   MoveFile(HauptpfadFileCh,UpdateFileCh);
   //aufräumen:
   delete &amp;Hauptpfad;
   delete &amp;UpdateFile;
   delete &amp;UpdateFile2;
   delete &amp;UpdateFileOld;
   delete &amp;HauptpfadFile;
   delete HauptpfadCh;
   delete UpdateFileCh;
   delete UpdateFile2Ch;
   delete UpdateFileOldCh;
   delete HauptpfadFileCh;
  }
</code></pre>
<p>Gruß BCB6-User</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/91309/probleme-mit-movefile</link><generator>RSS for Node</generator><lastBuildDate>Tue, 07 Jul 2026 18:41:45 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/91309.rss" rel="self" type="application/rss+xml"/><pubDate>Sun, 07 Nov 2004 12:13:03 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit MoveFile on Sun, 07 Nov 2004 12:13:03 GMT]]></title><description><![CDATA[<p>Hallo,<br />
Ich habe ein Problem mit MoveFile:<br />
Ich habe zu meinem Programm ein automatisches Update gemacht. Die neuen Dateien werden unter &quot;Dateiname.update&quot; gespeichert. Die StringList &quot;Updates&quot; enthält die Namen der *.update Dateien mit vollem Pfad. Jetzt wollte ich als erstes die Dateien, die bereits vorhanden sind umbenennen zu &quot;Dateiname.old&quot; und dann die *.update-Dateien Die Dateiendung nach &quot;&quot; (leer) umbenennen. Der Code wurde sehr lang und umständlich, aber es lässt sich bis jetzt ausführen. Aber dann kommt der Fehler:<br />
&quot;Im Projekt... trat ein Fehler mit folgender Meldung auf: 'Zugriffsverletzung bei 0x0040f60'. Prozess angehalten. Mit Einzelne Anweisung oder Start fortsetzen.&quot;<br />
Wie könnte ich den Code besser schreiben?<br />
Hier der Code:</p>
<pre><code class="language-cpp">for(int i=0; i &lt; Updates-&gt;Count; i++)
  {
   //chars zur Erleichterung:
   LMDLabel5-&gt;Caption=&quot;Datei &quot;+AnsiString(i)+&quot; wird geupdatet&quot;;
   AnsiString Hauptpfad = ExtractFilePath(Application-&gt;ExeName);
   char *HauptpfadCh;
   HauptpfadCh = Hauptpfad.c_str();
   AnsiString UpdateFile = ChangeFileExt(Updates-&gt;Strings[i],&quot;&quot;);
   char *UpdateFileCh;
   UpdateFileCh = UpdateFile.c_str();
   AnsiString UpdateFile2 = Hauptpfad+UpdateFile;
   char *UpdateFile2Ch;
   UpdateFile2Ch = UpdateFile2.c_str();
   AnsiString UpdateFileOld = UpdateFile+&quot;.old&quot;;
   char *UpdateFileOldCh;
   UpdateFileOldCh = UpdateFileOld.c_str();
   AnsiString HauptpfadFile = Hauptpfad+Updates-&gt;Strings[i];
   char *HauptpfadFileCh;
   HauptpfadFileCh = HauptpfadFile.c_str();
   //eigentliche Dateioperation:
   if(FileExists(Updates-&gt;Strings[i]))
    {
     MoveFile(UpdateFile2Ch,UpdateFileOldCh);
    }
   MoveFile(HauptpfadFileCh,UpdateFileCh);
   //aufräumen:
   delete &amp;Hauptpfad;
   delete &amp;UpdateFile;
   delete &amp;UpdateFile2;
   delete &amp;UpdateFileOld;
   delete &amp;HauptpfadFile;
   delete HauptpfadCh;
   delete UpdateFileCh;
   delete UpdateFile2Ch;
   delete UpdateFileOldCh;
   delete HauptpfadFileCh;
  }
</code></pre>
<p>Gruß BCB6-User</p>
]]></description><link>https://www.c-plusplus.net/forum/post/646590</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/646590</guid><dc:creator><![CDATA[BCB6-User]]></dc:creator><pubDate>Sun, 07 Nov 2004 12:13:03 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit MoveFile on Sun, 07 Nov 2004 13:47:42 GMT]]></title><description><![CDATA[<pre><code class="language-cpp">String TargetPath = ExtractFilePath(Application-&gt;ExeName);
  for(int i = 0; i &lt; Updates-&gt;Count; i++)
  {
    String FullSource = Updates-&gt;Strings[i];
    String FullTarget = ChangeFileExt(TargetPath + ExtractFileName(FullSource), &quot;&quot;);

    if (FileExists(FullTarget) &amp;&amp; RenameFile(FullTarget, FullTarget + &quot;.old&quot;) == false)
      ShowMessage(&quot;Konnte existierende Datei nicht umbenennen (&quot; + FullTarget + &quot;)&quot;);

    if (CopyFile(FullSource.c_str(), FullTarget.c_str(), true) == false)
      ShowMessage(&quot;Konnte existierende Datei nicht ersetzen (&quot; + FullTarget + &quot;)&quot;);
  }
</code></pre>
<p>Ungetestet.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/646680</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/646680</guid><dc:creator><![CDATA[Jansen]]></dc:creator><pubDate>Sun, 07 Nov 2004 13:47:42 GMT</pubDate></item></channel></rss>