how do check whether a particular file is present in a folder in c++(turbo )

Recommended Answers

All 5 Replies

http://www.codeblocks.org/
http://www.microsoft.com/express/
Both are FREE (except for the time taken to download)
Both WIPE THE FLOOR with the fossil you have.
Both will serve you well when you want to actually USE the OS you're running on.

Have you considered that your 20 year old fossil might not like
- filenames longer than 8 characters
- filenames with spaces
- filenames encoded in unicode
- filenames with characters which are not ASCII
- filenames which are not on a FAT16 file system
And that's just the beginning of all the pain and struggle which awaits.

#include <iostream>
#include <fstream>

using namespace std;

int main(int argc, char* argv[])
{
	ifstream file;

	string folderPath("C:\\");
	string fileName("boot1.ini");

	string filePath(folderPath);
	filePath += fileName;

	file.open(filePath.c_str());

	if (file.is_open()) {
		cout << "File is present";
	}
	else {
		cout << "File is not present";
	}

	file.close();

	return 0;
}

This program may help you...

Doubtful - it won't compile with TurboCrap, and it wasn't posted with code tags.
Does anybody bother to read intro threads?

thx

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.