今まで知らなかった関数を見つけたのでメモ。
1 | string filePath = @"C:\TestFolder\TestFile.txt" ; |
2 |
3 | //ファイルの拡張子を取得する |
4 | string val1 = System.IO.Path.GetExtension(filePath); |
5 | //var1は".txt"となる。 |
6 |
7 | //ファイルの拡張子を変更する |
8 | string val2 = System.IO.Path.ChangeExtension(filePath, "pdf" ); |
9 | //val2は"C:\TestFolder\TestFile.pdf"となる。 |