<?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 GetFullPath]]></title><description><![CDATA[<p>Hallo Zusammen ich habe die Aufgabe ein Programm zu schreiben, bei dem die 10 größten Dateien aus einem Verzeichnis/ Verzeichnisbeum ngezeigt werden sollen.<br />
Nun habe ich jedoch ein Problem mit der GetFullPath Funktion. Diese Funktion liefert mir immer den Pfad indem das Programm gerade läuft und nicht den Pfad der gerade gefundenen Datei.</p>
<p>Hier ist einmal mein Programm code:</p>
<pre><code>int listen(char *directory)
{
    WIN32_FIND_DATA FData;
    HANDLE hSearch = FindFirstFile(directory,&amp;FData);
    BOOL MoreFiles = FALSE;
    int cnt_dir = 0, cnt_file  = 0;
    //TCHAR *szFileName;
    DWORD dwRet;
    DWORD bufferLen = 0;
    TCHAR *buffer = new TCHAR[bufferLen];
    TCHAR *filePart;

    if (hSearch == INVALID_HANDLE_VALUE)
    {
       return -1;
    }

    do
    {
     if (!( (FData.cFileName[0]=='.') &amp;&amp; ( (FData.cFileName[1]=='.' &amp;&amp; FData.cFileName[2]==0) || FData.cFileName[1]==0 ) ))
     { // Ist das ein Ordner ?
      if(FData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
      {
          // Den Ordnernamen ausgeben
          cout&lt;&lt;&quot;(Ordner) &quot;&lt;&lt;FData.cFileName&lt;&lt;endl;
          bufferLen = GetFullPathName(FData.cFileName, bufferLen, buffer, &amp;filePart);
          delete [] buffer;

          if (bufferLen &gt; 0)
          {
             buffer = new TCHAR[bufferLen+1];

             dwRet = GetFullPathName(FData.cFileName, bufferLen+1, buffer, &amp;filePart);

                  if (dwRet &lt;= bufferLen)
                  {
                      // succeeded:
                      _tprintf(_T(&quot;FullName: %s\n&quot;), buffer);
                      listen(buffer);
                  }

          }
          cnt_dir++; // Ordnerzähler um 1 erhöhen
      }
      // Wenn nicht
      else
      {
        // Den Dateinamen ausgeben
        cout&lt;&lt;&quot;(Datei)&quot;&lt;&lt;FData.cFileName&lt;&lt;endl;

      }

      }
    }while (FindNextFile(hSearch,&amp;FData));

    FindClose(hSearch);
    cin.get();
}

int main(int argc, char *argv[])
{
    listen(&quot;C:\\*.*&quot;);
    getchar();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/topic/198697/probleme-mit-getfullpath</link><generator>RSS for Node</generator><lastBuildDate>Wed, 29 Apr 2026 02:59:20 GMT</lastBuildDate><atom:link href="https://www.c-plusplus.net/forum/topic/198697.rss" rel="self" type="application/rss+xml"/><pubDate>Sat, 24 Nov 2007 12:39:20 GMT</pubDate><ttl>60</ttl><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 12:39:20 GMT]]></title><description><![CDATA[<p>Hallo Zusammen ich habe die Aufgabe ein Programm zu schreiben, bei dem die 10 größten Dateien aus einem Verzeichnis/ Verzeichnisbeum ngezeigt werden sollen.<br />
Nun habe ich jedoch ein Problem mit der GetFullPath Funktion. Diese Funktion liefert mir immer den Pfad indem das Programm gerade läuft und nicht den Pfad der gerade gefundenen Datei.</p>
<p>Hier ist einmal mein Programm code:</p>
<pre><code>int listen(char *directory)
{
    WIN32_FIND_DATA FData;
    HANDLE hSearch = FindFirstFile(directory,&amp;FData);
    BOOL MoreFiles = FALSE;
    int cnt_dir = 0, cnt_file  = 0;
    //TCHAR *szFileName;
    DWORD dwRet;
    DWORD bufferLen = 0;
    TCHAR *buffer = new TCHAR[bufferLen];
    TCHAR *filePart;

    if (hSearch == INVALID_HANDLE_VALUE)
    {
       return -1;
    }

    do
    {
     if (!( (FData.cFileName[0]=='.') &amp;&amp; ( (FData.cFileName[1]=='.' &amp;&amp; FData.cFileName[2]==0) || FData.cFileName[1]==0 ) ))
     { // Ist das ein Ordner ?
      if(FData.dwFileAttributes == FILE_ATTRIBUTE_DIRECTORY)
      {
          // Den Ordnernamen ausgeben
          cout&lt;&lt;&quot;(Ordner) &quot;&lt;&lt;FData.cFileName&lt;&lt;endl;
          bufferLen = GetFullPathName(FData.cFileName, bufferLen, buffer, &amp;filePart);
          delete [] buffer;

          if (bufferLen &gt; 0)
          {
             buffer = new TCHAR[bufferLen+1];

             dwRet = GetFullPathName(FData.cFileName, bufferLen+1, buffer, &amp;filePart);

                  if (dwRet &lt;= bufferLen)
                  {
                      // succeeded:
                      _tprintf(_T(&quot;FullName: %s\n&quot;), buffer);
                      listen(buffer);
                  }

          }
          cnt_dir++; // Ordnerzähler um 1 erhöhen
      }
      // Wenn nicht
      else
      {
        // Den Dateinamen ausgeben
        cout&lt;&lt;&quot;(Datei)&quot;&lt;&lt;FData.cFileName&lt;&lt;endl;

      }

      }
    }while (FindNextFile(hSearch,&amp;FData));

    FindClose(hSearch);
    cin.get();
}

int main(int argc, char *argv[])
{
    listen(&quot;C:\\*.*&quot;);
    getchar();
    return 0;
}
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409312</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409312</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sat, 24 Nov 2007 12:39:20 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 12:51:54 GMT]]></title><description><![CDATA[<p>Wenn es Dir nur um den absoluten Pfad zur gerade gefundenen Datei geht, kannst Du Dir den doch zusammenbasteln. Die Funktion wird doch mit nem Pfad aufgeruden, also:<br />
[Pfad ohne Suchspezifikation] + [\] + [Dateiname] = [absoluter Pfad] <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> .</p>
<p>Vllt ist das noch interessant <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f609.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--winking_face"
      title=";)"
      alt="😉"
    /> :<br />
<a href="http://www.c-plusplus.net/forum/viewtopic-var-t-is-168044-and-highlight-is-%2Arekursiv%2A.html" rel="nofollow">http://www.c-plusplus.net/forum/viewtopic-var-t-is-168044-and-highlight-is-*rekursiv*.html</a><br />
(Ich meine die Funktion 'ScanFoldersForFiles' weiter unten.)</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409322</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409322</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 24 Nov 2007 12:51:54 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 13:16:59 GMT]]></title><description><![CDATA[<p>Das mit dem Zusammenbauen habe ich auch schon probiert, aber irgendwie klappt das nicht. Habe es mal mit StrCat versucht. Hast du noch ne andere Idee? Ich muss ja auch mit dem Zusammengesetzten Pfad in den Unterverzeichnissen weiter suchen.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409331</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409331</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sat, 24 Nov 2007 13:16:59 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 13:29:16 GMT]]></title><description><![CDATA[<p>Hast Du Dir den Link überhaupt angeguckt (oder bist Du auf C angewiesen) ?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409335</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409335</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 24 Nov 2007 13:29:16 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 13:40:44 GMT]]></title><description><![CDATA[<p>Ich plädiere: Macht CodeFinder endlich zum Moderator, bitte! Ohne CodeFinder ist einfach nichts los im WinAPI Forum.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409339</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409339</guid><dc:creator><![CDATA[fan]]></dc:creator><pubDate>Sat, 24 Nov 2007 13:40:44 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 13:40:56 GMT]]></title><description><![CDATA[<p>Ja habe ich mir durchgelesen. Aber ich soll die API Funktionen für Dateioperationen nutzen. Das ist die Vorgabe unseres Lehrers. Von daher wäre mir das so wie ich es vor hatte lieber. Ich müsste halt nur den Pfad zusammensetzen. Aber mit StrCat gehts nicht. Oder haste noch ne Idee?</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409340</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409340</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sat, 24 Nov 2007 13:40:56 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 13:53:16 GMT]]></title><description><![CDATA[<p>SqaureOne schrieb:</p>
<blockquote>
<p>Aber ich soll die API Funktionen für Dateioperationen nutzen.</p>
</blockquote>
<p>lol, das hab ich doch <img
      src="https://www.c-plusplus.net/forum/plugins/nodebb-plugin-emoji/emoji/emoji-one/1f4a1.png?v=ab1pehoraso"
      class="not-responsive emoji emoji-emoji-one emoji--light_bulb"
      title=":bulb:"
      alt="💡"
    /> . Hier wird bei mir gebastelt:</p>
<pre><code class="language-cpp">// ...
strSearchArg = strSrc + cString(win32FinData.cFileName);
strSearchArg.append(cString(STRING(&quot;\\*&quot;)), 0, 3); 
// ...
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409351</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409351</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 24 Nov 2007 13:53:16 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 14:19:01 GMT]]></title><description><![CDATA[<p>Ok, ich habe es nun eingebaut und bekomme Compilerfehler:</p>
<p>Aufruf der Undefinierten Funktion 'cString'<br />
append ist kein Element von Ansi String<br />
Aufruf der undefinierten Funktion 'String'</p>
<pre><code>#include &lt;vcl.h&gt;
#include&lt;String&gt;
#include&lt;Windows.h&gt;
#pragma hdrstop
using namespace std;
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409367</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409367</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sat, 24 Nov 2007 14:19:01 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 14:26:41 GMT]]></title><description><![CDATA[<p>Was programmiert ihr denn (WinAPI oder VCL)?<br />
Mit den VCL-Funktionen ist es doch dann einfacher, da diese direkt mit dem Datentyp AnsiString zusammenarbeiten.</p>
<p>Oder aber du verwendest direkt die Datentypen der Standard-C++ Bibliothek: std::string.</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409372</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409372</guid><dc:creator><![CDATA[Th]]></dc:creator><pubDate>Sat, 24 Nov 2007 14:26:41 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 14:50:44 GMT]]></title><description><![CDATA[<p>Wir sollen die API Fumktionen nutzen. Wir programmieren mit dem Borland Builder 6</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409383</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409383</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sat, 24 Nov 2007 14:50:44 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sat, 24 Nov 2007 19:27:17 GMT]]></title><description><![CDATA[<p>Ließ Dir endlich den verlinkten Post durch...</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409536</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409536</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sat, 24 Nov 2007 19:27:17 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sun, 25 Nov 2007 00:43:14 GMT]]></title><description><![CDATA[<p>Ich habe mir den Link angeschaut. Habe nun noch</p>
<pre><code>#ifndef UNICODE
  typedef char        CSTRG;
  typedef char*       PCSTRG;
  typedef const char* CPCSTRG;
#else
  typedef wchar_t        CSTRG;
  typedef wchar_t*       PCSTRG;
  typedef const wchar_t* CPCSTRG;
#endif // !UNICODE
</code></pre>
<p>eingebaut aber immer noch die zuvor erwähnten Fehler. Kannst du mir nicht nochmal einen kleinen Tipp geben?</p>
<p>Wäre super nett Danke!!!</p>
]]></description><link>https://www.c-plusplus.net/forum/post/1409641</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409641</guid><dc:creator><![CDATA[SqaureOne]]></dc:creator><pubDate>Sun, 25 Nov 2007 00:43:14 GMT</pubDate></item><item><title><![CDATA[Reply to Probleme mit GetFullPath on Sun, 25 Nov 2007 01:18:55 GMT]]></title><description><![CDATA[<p>Hm, steht eigentlich auch in dem Thread:</p>
<pre><code class="language-cpp">#ifdef UNICODE
  typedef std::wstring cString;
  // ...
#else
  typedef std::string cString;
  // ...
#endif // UNICODE
</code></pre>
]]></description><link>https://www.c-plusplus.net/forum/post/1409648</link><guid isPermaLink="true">https://www.c-plusplus.net/forum/post/1409648</guid><dc:creator><![CDATA[CodeFinder]]></dc:creator><pubDate>Sun, 25 Nov 2007 01:18:55 GMT</pubDate></item></channel></rss>