Zum Inhalt springen
View in the app

A better way to browse. Learn more.

Fachinformatiker.de

A full-screen app on your home screen with push notifications, badges and more.

To install this app on iOS and iPadOS
  1. Tap the Share icon in Safari
  2. Scroll the menu and tap Add to Home Screen.
  3. Tap Add in the top-right corner.
To install this app on Android
  1. Tap the 3-dot menu (⋮) in the top-right corner of the browser.
  2. Tap Add to Home screen or Install app.
  3. Confirm by tapping Install.

Directory auslesen - Dateien in Array o.ä.?

Empfohlene Antworten

Veröffentlicht

ich nutzte vc++ mit mfc und möchte mir nun alle dateien in einem von mir festgelegten verzeichnis auslesen, um diese dann nacheinander zu verarbeiten.

Wie geht sowas? :confused:

Ich habe mir zum Einlesen eines Verzeichnisses eine eigene kleine Klasse geschrieben:


//DStrukturen.h

#include <afxtempl.h>


class DStrukturen  

{

private:

	enum type {dir,file};

	typedef struct cdFile {type Typ; CString cdfile; CString path;} CDFile;

	int files,dirs;

	CString Structpath;

	void readstructure(CDFile& newfile,CString& CDpath);

public:

	CArray<CDFile> Branchlist;

	DStrukturen(CString CDpath);

	virtual ~DStrukturen() {Branchlist.RemoveAll();}

	void output() {int t=Branchlist.GetCount(); for (int i=0; i<t;i++) 

		TRACE("%s\\%s\n",Branchlist[i].path,Branchlist[i].cdfile); TRACE("Dirs: %i Files: %i",dirs,files);}

};

// .cpp

#include "DStrukturen.h"


DStrukturen::DStrukturen(CString CDpath="P:\\")

{

	files=dirs=0;

	CDFile newfile;

	readstructure(newfile,CDpath);

}


void DStrukturen::readstructure(CDFile& newfile,CString& CDpath)

{

CFileFind finder;

CString findpath=CDpath+"\\*.*";

BOOL loop= finder.FindFile(findpath);

while (loop)

  {

    bWorking = finder.FindNextFile();

	if (!finder.IsDots())

		{

			newfile.path=CDpath;

			newfile.cdfile=finder.GetFileName();

			if (finder.IsDirectory())

			{

				dirs++;

				newfile.Typ=dir;

				readstructure(newfile,CDpath+"\\"+finder.GetFileName());

			}

			else

			{

				files++;

				newfile.Typ=file;

				Branchlist.InsertAt(0,newfile);

			}

		}

	}

}


//Aufruf im Programm:

DStrukturen str("C:"); // Erstellen des Reader-Objekts mit gleichzeitigem Einlesen der kompletten Directory-Strukur

str.output(); // gibt erstmal alles ins Trace-Fenster aus.

Archiv

Dieses Thema wurde archiviert und kann nicht mehr beantwortet werden.

Configure browser push notifications

Chrome (Android)
  1. Tap the lock icon next to the address bar.
  2. Tap Permissions → Notifications.
  3. Adjust your preference.
Chrome (Desktop)
  1. Click the padlock icon in the address bar.
  2. Select Site settings.
  3. Find Notifications and adjust your preference.