Reputation: 327
I'm writing an parser for iTunes XML file and I'm trying to parse the file location to permit to the application to recover the folder.jpg from de folder.
I'm creating an URI from the location of itunes.xml in this format:
\\localhost\C:\MP3 Collection\Álbuns\# - E\A\a-ha\[1985] Hunting High And Low\01. Take On Me.mp3
I need to extract the 01. Take On Me.mp3
substring and replace it with folder.jpg
.
Remember that this string is different in each file.
Upvotes: 3
Views: 300
Reputation: 217361
You can use the Path.GetDirectoryName Method and the Path.Combine Method:
var s = @"\\localhost\C:\MP3 Collection\Álbuns\# - E\A\a-ha\[1985] Hunting High And Low\01. Take On Me.mp3";
var result = Path.Combine(Path.GetDirectoryName(s), "folder.jpg");
// result == @"\\localhost\C:\MP3 Collection\Álbuns\# - E\A\a-ha\[1985] Hunting High And Low\folder.jpg"
Upvotes: 4