c++ how to remove filename from path string

The easiest way is to use find_last_of member function of std::string string s1(“../somepath/somemorepath/somefile.ext”); string s2(“..\\somepath\\somemorepath\\somefile.ext”); cout << s1.substr(0, s1.find_last_of(“\\/”)) << endl; cout << s2.substr(0, s2.find_last_of(“\\/”)) << endl; This solution works with both forward and back slashes.

Docker: in memory file system

There’s no difference between the storage of the image and the base filesystem of the container, the layered FS accesses the images layers directly as a RO layer, with the container using a RW layer above to catch any changes. Therefore your goal of having the container running in memory while the Docker installation remains … Read more

Is there a faster way to scan through a directory recursively in .NET?

This implementation, which needs a bit of tweaking is 5-10X faster. static List<Info> RecursiveScan2(string directory) { IntPtr INVALID_HANDLE_VALUE = new IntPtr(-1); WIN32_FIND_DATAW findData; IntPtr findHandle = INVALID_HANDLE_VALUE; var info = new List<Info>(); try { findHandle = FindFirstFileW(directory + @”\*”, out findData); if (findHandle != INVALID_HANDLE_VALUE) { do { if (findData.cFileName == “.” || findData.cFileName == … Read more

Flutter: how to delete a file inside the Flutter app directory

You can copy paste run full code below You can use file.delete() code snippet Future<String> get _localPath async { final directory = await getApplicationDocumentsDirectory(); return directory.path; } Future<File> get _localFile async { final path = await _localPath; print(‘path ${path}’); return File(‘$path/counter.txt’); } Future<int> deleteFile() async { try { final file = await _localFile; await file.delete(); … Read more