Click here to Skip to main content
15,891,864 members
Home / Discussions / C / C++ / MFC
   

C / C++ / MFC

 
GeneralRe: check box in the menu pane Pin
Chandrasekharan P8-Jan-08 0:20
Chandrasekharan P8-Jan-08 0:20 
GeneralRe: check box in the menu pane Pin
Chandrasekharan P8-Jan-08 0:35
Chandrasekharan P8-Jan-08 0:35 
GeneralRe: check box in the menu pane Pin
Chandrasekharan P8-Jan-08 19:04
Chandrasekharan P8-Jan-08 19:04 
Generalcall a object in all classes mfc vc++ Pin
guru moorthy.k7-Jan-08 23:43
guru moorthy.k7-Jan-08 23:43 
GeneralRe: call a object in all classes mfc vc++ Pin
toxcct7-Jan-08 23:53
toxcct7-Jan-08 23:53 
QuestionRe: call a object in all classes mfc vc++ Pin
Matthew Faithfull7-Jan-08 23:56
Matthew Faithfull7-Jan-08 23:56 
GeneralRe: call a object in all classes mfc vc++ Pin
CPallini8-Jan-08 0:06
mveCPallini8-Jan-08 0:06 
GeneralFile information of the folder content. Pin
CodingLover7-Jan-08 23:25
CodingLover7-Jan-08 23:25 
Hi all,

I'm looking to read a folder which contain number of files. I want to get some details of those files, like Name, Size, Date Created. Those details I can see from the details view of the folder.

To start I try to find the file name as follows.

Try to find the paths of all files included in a folder as follows.

nt CCountOne::SearchDirectory(vector<string> &refvecFiles,const string &refcstrRootDirectory, const string &refcstrExtension, bool bSearchSubdirectories)
{
	bSearchSubdirectories = true;	// Handle the directories and subdirectories

	string strFilePath;	// Filepath
	string strExtension;// Extension
	string strPattern;	// Pattern

	HANDLE hFile;	// File handler

	WIN32_FIND_DATA FileInformation;	// File information, use relevent structure of WinAPI

// Set the path pattern
	strPattern = refcstrRootDirectory + "\\*.*";
	hFile = ::FindFirstFile(strPattern.c_str(), &FileInformation);// Get the handler pointed

	int iCount = 0;// Number of iterations

	if(hFile != INVALID_HANDLE_VALUE)
	{
		do
		{
			if(FileInformation.cFileName[0] != '.')
			{
				strFilePath.erase();// Clear the exsisting path
				strFilePath = refcstrRootDirectory + "\\" + FileInformation.cFileName;// Set the new path

				if(FileInformation.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
				{
					
					if(bSearchSubdirectories)
					{
					// Search the subdirectories
						int iRC = SearchDirectory(refvecFiles, strFilePath, refcstrExtension, bSearchSubdirectories);
						if(iRC)
						{
							return iRC;
						}
					}
					else
					{
					// Extension check
						strExtension = FileInformation.cFileName;// Use the file name
						strExtension = strExtension.substr(strExtension.rfind(".") + 1);

						cout << strExtension << endl;

						if(strExtension == refcstrExtension)
						{
						// Save the file name
							refvecFiles.push_back(strFilePath);
						}

					}
				}
				else
				{
					cout << "Error_Two" << endl;
				}
			}
		}while(::FindNextFile(hFile, &FileInformation) == TRUE);

		// Close the handle
		::FindClose(hFile);

		DWORD dwError = ::GetLastError();
		if(dwError != ERROR_NO_MORE_FILES)
		{
			return dwError;
		}
	}

	return 0;
}
</string>


In this code set the folder path and start work.

void CCountOne::GetStart(void)
{
	int iRC = 0;
	vector<string> vecSrfFiles;// bin file name

// Search "C:\Bin Files\Bin" for "*.srf" files
// Subdirectories also included
	iRC = SearchDirectory(vecSrfFiles, "C:\\Bin Files\\Bin", "srf", true);
	
// Check the error
	if(iRC != 0)
	{
		cout << "Error_One " << iRC << endl;
	}

// Print the result
	for(vector<string>::iterator iterSrf = vecSrfFiles.begin(); iterSrf != vecSrfFiles.end(); ++iterSrf)
	{
		cout << *iterSrf << endl;
	}
}
</string></string>


But it don't give any file path. Try to debug and check, seems
if(FileInformation.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY)
of code one stuck me with.

Can you guys just look at it.

I appreciate your help all the time...
Eranga Smile | :)

QuestionRe: File information of the folder content. Pin
David Crow8-Jan-08 3:27
David Crow8-Jan-08 3:27 
GeneralRe: File information of the folder content. Pin
CodingLover8-Jan-08 15:43
CodingLover8-Jan-08 15:43 
GeneralRe: File information of the folder content. Pin
CodingLover8-Jan-08 19:58
CodingLover8-Jan-08 19:58 
GeneralMFC: Getting my icon-styled CListCtrl to wrap onto a new row/column Pin
Sternocera7-Jan-08 23:24
Sternocera7-Jan-08 23:24 
QuestionRe: MFC: Getting my icon-styled CListCtrl to wrap onto a new row/column Pin
Mark Salsbery8-Jan-08 9:15
Mark Salsbery8-Jan-08 9:15 
GeneralRe: MFC: Getting my icon-styled CListCtrl to wrap onto a new row/column Pin
Sternocera8-Jan-08 22:13
Sternocera8-Jan-08 22:13 
Generalarrow keys on CMenu Pin
vickyoncodeguru7-Jan-08 23:24
vickyoncodeguru7-Jan-08 23:24 
Generalcomman variable for all clasess. Pin
Paulraj G7-Jan-08 23:20
Paulraj G7-Jan-08 23:20 
GeneralRe: comman variable for all clasess. Pin
toxcct7-Jan-08 23:24
toxcct7-Jan-08 23:24 
GeneralRe: comman variable for all clasess. Pin
Paulraj G7-Jan-08 23:31
Paulraj G7-Jan-08 23:31 
GeneralRe: comman variable for all clasess. Pin
CPallini7-Jan-08 23:33
mveCPallini7-Jan-08 23:33 
GeneralRe: comman variable for all clasess. Pin
Rajesh R Subramanian8-Jan-08 0:41
professionalRajesh R Subramanian8-Jan-08 0:41 
QuestionRe: comman variable for all clasess. Pin
David Crow8-Jan-08 3:30
David Crow8-Jan-08 3:30 
Questionprojecttttttt Pin
Member 47567097-Jan-08 23:09
Member 47567097-Jan-08 23:09 
GeneralRe: projecttttttt Pin
toxcct7-Jan-08 23:11
toxcct7-Jan-08 23:11 
GeneralRe: projecttttttt Pin
Member 47567097-Jan-08 23:20
Member 47567097-Jan-08 23:20 
GeneralRe: projecttttttt Pin
Cedric Moonen7-Jan-08 23:17
Cedric Moonen7-Jan-08 23:17 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.