Trying to append folder size to a folder name.
Before: After:
Folder 1 -----> Folder 1 (1.5 Gig)
Folder 2 -----> Folder 2 (400 MB)
Folder 3 -----> Folder 3 (900 KB)
Once things are put into the folder they pretty much won't change for the most part, as I had been doing this manually for a while now over time. On rare occasions they might, but I always do it manually and I guess I could have a check button that rechecks the size & modifies name, but for right now it is not necessary.
_________
Thanks for everyone's input, I could not even get off the ground last time I tried & again today. I try to put in a little time for what I thought would be quick day or two task & here we are.
On Windows 10 Home 64Bit I am using Embaracadero 6.3 install from summer of 2021 & compiling with TDM-GCC 9.2.0 64-bit release. I also tried with 32 bit and the error I get is....
"... [Error] 'filesystem' is not a namespace-name"
I also tried with Microsoft Visual Studio Community 2019 Version 16.10.4 installed this summer....in Debug/x86 & with same compile error " namespace "std" has no member "filesystem" "
How do I find out what compiler I am using in VS?
_________
I tried this today from what I have read from another poster & no go...must have been around the time of C++17 pre-release.
#include <experimental/filesystem>
namespace fs = std::experimental::filesystem;
//Tried below separately too
#include <filesystem>
namespace fs = std::experimental::filesystem;
At this point I am just going to try to get this working & cout some properties from this MS code below to ease into my project. Never seen wcout & wstring, those are wide string & outputs I guess. When I do a simple "wstring myWString("Hello");" it does not work, is this unicode or something?
What is this "L" in this wide output stream being sent?
wos << L"root_name() = " << pathToDisplay.root_name() << endl
I think with a recent install it should be C++20, but I don't know what "// compile by using: /EHsc /W4 /permissive-" that is in comment below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
|
// filesystem_path_example.cpp
// compile by using: /EHsc /W4 /permissive- /std:c++17 (or later)
#include <string>
#include <iostream>
#include <sstream>
#include <filesystem>
using namespace std;
using namespace std::filesystem;
wstring DisplayPathInfo()
{
// This path may or may not refer to an existing file. We are
// examining this path string, not file system objects.
path pathToDisplay(L"C:/FileSystemTest/SubDir3/SubDirLevel2/File2.txt ");
wostringstream wos;
int i = 0;
wos << L"Displaying path info for: " << pathToDisplay << endl;
for (path::iterator itr = pathToDisplay.begin(); itr != pathToDisplay.end(); ++itr)
{
wos << L"path part: " << i++ << L" = " << *itr << endl;
}
wos << L"root_name() = " << pathToDisplay.root_name() << endl
<< L"root_path() = " << pathToDisplay.root_path() << endl
<< L"relative_path() = " << pathToDisplay.relative_path() << endl
<< L"parent_path() = " << pathToDisplay.parent_path() << endl
<< L"filename() = " << pathToDisplay.filename() << endl
<< L"stem() = " << pathToDisplay.stem() << endl
<< L"extension() = " << pathToDisplay.extension() << endl;
return wos.str();
}
int main()
{
wcout << DisplayPathInfo() << endl;
// wcout << ComparePaths() << endl; // see following example
wcout << endl << L"Press Enter to exit" << endl;
wstring input;
getline(wcin, input);
}
|
"The code produces this output:
Output
Displaying path info for: C:\FileSystemTest\SubDir3\SubDirLevel2\File2.txt
path part: 0 = C:
path part: 1 = \
path part: 2 = FileSystemTest
path part: 3 = SubDir3
path part: 4 = SubDirLevel2
path part: 5 = File2.txt
root_name() = C:
root_path() = C:\
relative_path() = FileSystemTest\SubDir3\SubDirLevel2\File2.txt
parent_path() = C:\FileSystemTest\SubDir3\SubDirLevel2
filename() = File2.txt
stem() = File2
extension() = .txt "