我有一個定義的文件的路徑的字符串:字符串插入文件擴展名C#前一個文件路徑字符串
string duplicateFilePath = D:\User\Documents\processed\duplicate_files\file1.jpg;
我將文件移動到這個位置,但與相同的,有時一個文件名字已經準備好了。在這種情況下,我想區分文件名。我有每個文件的crc值可用,所以我認爲可能很好用來確保單個文件名。我可以創建:
string duplicateFilePathWithCrc = duplicateFilePath + "(" + crcValue + ")";
但是這給:
D:\User\Documents\processed\duplicate_files\file1.jpg(crcvalue);
,我需要:
D:\User\Documents\processed\duplicate_files\file1(crcvalue).jpg;
我怎樣才能把crcvalue到文件擴展名之前的字符串,銘記在文件路徑和文件擴展名中可能有其他的。
嘗試使用此http://msdn.microsoft.com/en-us/library/system.io.path.getextension(v=vs.110)。 aspx –