I have done research but my app downloads mp3 files every once in a while I get weird filename which doesn't hurt until I try to burn them to CD. I am using this media burner from CodeProject.
Below is a good example:
The Animals - House of the Rising Sun (1964) + clip compilation ♫♥ 50 YEARS - counting.mp3
I have some code to try and catch illegal characters but it doesn't stop this filename. Is there a better way to catch the weird stuff?
The code I use currently is:
public static string RemoveIllegalFileNameChars(string input, string replacement = "")
{
if (input.Contains("?"))
{
input = input.Replace('?', char.Parse(" "));
}
if (input.Contains("&"))
{
input = input.Replace('&', char.Parse("-"));
}
var regexSearch = new string(Path.GetInvalidFileNameChars()) +
new string(Path.GetInvalidPathChars());
var r = new Regex(string.Format("[{0}]", Regex.Escape(regexSearch)));
return r.Replace(input, replacement);
}
The CD file system is different to the OS file system, so those Path.GetInvalidX functions don't really apply to CDs.
I'm not sure, but possibly the standard you are looking at is ISO 9660 https://en.wikipedia.org/wiki/ISO_9660 Which has an extremely limited character set in filenames.
I think that Joliet extension to that standard must be in play: https://en.wikipedia.org/wiki/Joliet_(file_system) I think that maybe you are running into the filename length problem more than anything: "The specification only allows filenames to be up to 64 Unicode characters in length". Your filename is 90 characters long.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With