C#版
var filenpath = @"C:\Users\Directory\Filename.txt"; Console.WriteLine(Path.Combine(Path.GetDirectoryName(filenpath), Path.GetFileNameWithoutExtension(filenpath) + "Test" + Path.GetExtension(filenpath)));
C++版
filesystem::path path0 = filesystem::path("C:\\Users\\Directory\\Filename.txt"); std::cout<<path0.replace_filename(path0.filename().replace_extension("").string() + "Test" + path0.extension().string()).string();
出力
C:\Users\Directory\FilenameTest.txt