Suppose I have a folder called test.
Now I pass that folder into a program and it will output a file called test.xyz in the same directory that contains the target folder.
The general logic I'm using is something like
string outDir = Path.GetDirectoryName(path);
string outName = Path.GetFileName(path).TrimEnd("\\".ToCharArray()) + ".xyz";
string outFile = Path.Combine(outDir, outName);
Which works, but it seems kind of excessive to perform so many operations just to build my new filename.
1: Can I reduce the number of Path calls to achieve my result?
2: Can I do something about the second line to avoid trimming and also avoid using that add operation?