File Folder Manager API primarily Focused to assist c++ programmer in deal with File System Structure of Windows in the simplest way possible. Built on Visual Studio 2012. A high performance API in C++ With Easy Debugging Facility.
The Both Files are the only files of this API. You can use this API by just adding the Header File and CPP File in its respective project directory Like in
- Open the project that you have created as console application
- Then Just drag FileManager.cpp into "Source Files" visible directory inside project
- And then drag FileManager.h into "Header Files" visible directory inside project
- At Last Just Include the header inside your main cpp file as #include FileManager.h
- Now you're ready to go enjoy and for more information read the MD file.
In this you just have to call the built-in static functions of the API to do the file handling.
- Creating A File:
std::string filename = "D:\example.txt\\";
if ( FileManager::createFile(filename) )
{
std::cout << "Created file: " << filename << std::endl;
}
- Writing To A File:
std::string filename = "D:\example.txt\\";
if (FileManager::fileExists(filename))
{
std::cout << "Writing Into the File: \t" <<filename<< std::endl;
std::vector<std::string> newLines ;
newLines.push_back("Hello");
newLines.push_back("world!");
if (FileManager::writeLines(filename, newLines)) {
std::cout << "Wrote new lines to file: " << filename << std::endl;
}
}
- Reading From A File:
std::string filename = "D:\example.txt\\";
if (FileManager::fileExists(filename))
{
std::cout << "Reading the File: \t" <<filename<< std::endl;
std::vector<std::string> lines = FileManager::readLines(filename);
for (const auto& line : lines) {
std::cout << line << std::endl;
}
}
- Copying A File:
std::string filename = "D:\example.txt\\";
if (FileManager::fileExists(filename))
{
std::cout << "Copying the File: \t" <<filename<< std::endl;
if (FileManager::copyFile(filename, "D:\\np\\"))
{
std::cout << "File Copied: " << filename << std::endl;
}
}
- Creating A Folder:
std::string dir = "D:\\meetha\\";
if (FileManager::createDirectory(dir))
{
std::cout << "Directory Created : "<<dir << std::endl;
}
- Copying A Folder:
std::string dir = "D:\\meetha\\";
std::string source = "D:\\np\\";
if( FileManager::copyDirectory(source,dir))
{
std::cout << "Directory D:\\np\\ Copied to: "<<dir << std::endl;
}
- Deleting A Folder:
std::string dir = "D:\\meetha\\";
if (FileManager::deleteDirectory(dir))
{
std::cout << "Directory Deleted : "<<dir << std::endl;
}