<?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[Eine xcopy - Anwendung ( Verzeichnisse kopieren )]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich benötige eine Anwendung, die mir ein Verzeichnis ( mit Unterverzeichnissen ) kopiert. Das Quell- und das Zielverzeichniss soll über die Parameter der Anwendung übergeben werden.<br />
Hier mal mein Ansatz:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &lt;shellapi.h&gt;
#include &lt;iostream&gt;

#ifndef MAX_PATH
   #define MAX_PATH 255
#endif

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
   SHFILEOPSTRUCT sFileOperation;

   sFileOperation.fAnyOperationsAborted = false;

   memset( &amp;sFileOperation, 0, sizeof( SHFILEOPSTRUCT ) );

   if( argc == 3 )
   {
      sFileOperation.pFrom = argv[1];
      sFileOperation.pTo = argv[2];

      sFileOperation.wFunc = FOF_FILESONLY;

		sFileOperation.fFlags |= ( FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_SIMPLEPROGRESS );

      if( ::SHFileOperation(&amp;sFileOperation) == 0 )
      {
         // succeeded
         // ---------
         return 0;
      }
      else
      {
         // error during fileoperation
         // --------------------------
         DWORD dwError;
         dwError = GetLastError();

         cout &lt;&lt; dwError &lt;&lt; endl;
         cout &lt;&lt; sFileOperation.pFrom &lt;&lt; &quot; &quot; &lt;&lt; sFileOperation.pTo &lt;&lt; endl;
         getchar();

         return -2;
      }
   }
   else
   {
      // wrong parameter count
      // ---------------------
      return -1;
   }
}
</code></pre>
<p>Wieso lande ich immer im &quot;error during fileoperation&quot; Zweig meiner Verschachtelung? Mach ich noch irgendwas mit den Parametern falsch? Liegt es mal wieder an irgendwelchen Datentypumwandlung, die ich dafür machen müsste?</p>
<p>Schon mal vielen Dank im vorraus<br />
Mr.Yellow</p>
]]></description><link>https://www.c-plusplus.net/forum/topic/135328/eine-xcopy-anwendung-verzeichnisse-kopieren</link><generator>RSS for Node</generator><lastBuildDate>Sun, 12 Jul 2026 01:44:15 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/135328.rss" rel="self" type="application/rss+xml"/><pubDate>Wed, 01 Feb 2006 12:43:31 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 12:43:31 GMT]]></title><description><![CDATA[<p>Hallo,</p>
<p>ich benötige eine Anwendung, die mir ein Verzeichnis ( mit Unterverzeichnissen ) kopiert. Das Quell- und das Zielverzeichniss soll über die Parameter der Anwendung übergeben werden.<br />
Hier mal mein Ansatz:</p>
<pre><code>#include &quot;stdafx.h&quot;
#include &lt;windows.h&gt;
#include &lt;shellapi.h&gt;
#include &lt;iostream&gt;

#ifndef MAX_PATH
   #define MAX_PATH 255
#endif

using namespace std;

int _tmain(int argc, _TCHAR* argv[])
{
   SHFILEOPSTRUCT sFileOperation;

   sFileOperation.fAnyOperationsAborted = false;

   memset( &amp;sFileOperation, 0, sizeof( SHFILEOPSTRUCT ) );

   if( argc == 3 )
   {
      sFileOperation.pFrom = argv[1];
      sFileOperation.pTo = argv[2];

      sFileOperation.wFunc = FOF_FILESONLY;

		sFileOperation.fFlags |= ( FOF_NOCONFIRMATION | FOF_NOCONFIRMMKDIR | FOF_SIMPLEPROGRESS );

      if( ::SHFileOperation(&amp;sFileOperation) == 0 )
      {
         // succeeded
         // ---------
         return 0;
      }
      else
      {
         // error during fileoperation
         // --------------------------
         DWORD dwError;
         dwError = GetLastError();

         cout &lt;&lt; dwError &lt;&lt; endl;
         cout &lt;&lt; sFileOperation.pFrom &lt;&lt; &quot; &quot; &lt;&lt; sFileOperation.pTo &lt;&lt; endl;
         getchar();

         return -2;
      }
   }
   else
   {
      // wrong parameter count
      // ---------------------
      return -1;
   }
}
</code></pre>
<p>Wieso lande ich immer im &quot;error during fileoperation&quot; Zweig meiner Verschachtelung? Mach ich noch irgendwas mit den Parametern falsch? Liegt es mal wieder an irgendwelchen Datentypumwandlung, die ich dafür machen müsste?</p>
<p>Schon mal vielen Dank im vorraus<br />
Mr.Yellow</p>
]]></description><link>https://www.c-plusplus.net/forum/post/982946</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/982946</guid><dc:creator><![CDATA[Mr.Yellow]]></dc:creator><pubDate>Wed, 01 Feb 2006 12:43:31 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 12:54:39 GMT]]></title><description><![CDATA[<p>pFrom und pTo müssen doppelt Null-Terminiert sein, das ist wahrscheinlich bei Dir nicht der Fall.<br />
Kopiere lieber die Argumente argv in einen Puffer und hänge noch eine Null 'dran.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/982958</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/982958</guid><dc:creator><![CDATA[RR]]></dc:creator><pubDate>Wed, 01 Feb 2006 12:54:39 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 13:35:27 GMT]]></title><description><![CDATA[<p>Ich habe jetzt mal die Terminierung hinzugefügt:</p>
<pre><code>TCHAR tcSource[MAX_PATH];
      TCHAR tcDest[MAX_PATH];

      memcpy( tcSource, argv[1],  34  );
      memcpy( tcDest, argv[2], 16 );

      tcSource[17] = '\0';
      tcSource[18] = '\0';

      tcDest[8] = '\0';
      tcDest[9] = '\0';

      sFileOperation.pFrom = tcSource;
      sFileOperation.pTo = tcDest;
</code></pre>
<p>Laut Quickwatch beim debuggen, werden in die sFileOperation Struktur auch die richtigen Werte für pFrom und pTo eingetragen. Klappt aber leider immer noch nicht so richtig und ich lande noch immer im selben Zweig in der Verzweigung.</p>
<p>Mr.Yellow</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983015</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983015</guid><dc:creator><![CDATA[Mr.Yellow]]></dc:creator><pubDate>Wed, 01 Feb 2006 13:35:27 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 13:42:01 GMT]]></title><description><![CDATA[<p>Du hast auch deine Struct falsch initialisiert - in wFunc gehört die auszuführende Operation rein (für dich FO_COPY) und keine Kontrollflags.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983021</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983021</guid><dc:creator><![CDATA[CStoll (off)]]></dc:creator><pubDate>Wed, 01 Feb 2006 13:42:01 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 13:44:11 GMT]]></title><description><![CDATA[<p>Du solltest lieber schreiben.</p>
<pre><code class="language-cpp">ZeroMemory(tcSource,sizeof(tcSource));
lstrcpy(tcSource,argv[1]); //Rest ist NULL

ZeroMemory(tcDest,sizeof(tcDest));
lstrcpy(tcDest,argv[2]);
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/983023</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983023</guid><dc:creator><![CDATA[RR]]></dc:creator><pubDate>Wed, 01 Feb 2006 13:44:11 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 13:46:40 GMT]]></title><description><![CDATA[<p>CStoll (off) schrieb:</p>
<blockquote>
<p>Du hast auch deine Struct falsch initialisiert - in wFunc gehört die auszuführende Operation rein (für dich FO_COPY) und keine Kontrollflags.</p>
</blockquote>
<p>Das ist auch richtig (habe es übersehen). Ich hatte aber auch schon Probleme, wenn die Strings nicht doppelt Null-Terminiert waren.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983025</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983025</guid><dc:creator><![CDATA[RR]]></dc:creator><pubDate>Wed, 01 Feb 2006 13:46:40 GMT</pubDate></item><item><title><![CDATA[Reply to Eine xcopy - Anwendung ( Verzeichnisse kopieren ) on Wed, 01 Feb 2006 13:49:38 GMT]]></title><description><![CDATA[<p>Habt vielen Dank ...<br />
läuft nun einwandfrei.</p>
<p>MfG<br />
Mr.Yellow</p>
]]></description><link>https://www.c-plusplus.net/forum/post/983030</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/983030</guid><dc:creator><![CDATA[Mr.Yellow]]></dc:creator><pubDate>Wed, 01 Feb 2006 13:49:38 GMT</pubDate></item></channel></rss>