I search files and return FileInfo
as IEnumerable. I set a breakpoint in the Select
and see the filename passed in is e:\mp3\MP3_Amazon\Orchestra della Scala di Milano, Tullio Serafin,Herbert von Karajan, Maria \Maria Callas, Vol 4\01-15- Madama Butterfly Un bel dì, vedremo.mp3
When I loop through the IEnumerable and try to open the file as Stream I get an error System.IO.DirectoryNotFoundException
with the file. The FullName
member of the FileInfo misses the space that ends the part of the path Orchestra della Scala...
The path was created by Amazon's MP3 downloader (Amazon Music).
I now wonder if and how it's possible to access the file programatically. Why is the path split in it's parts and each part stripped from trailing spaces at all whe the FileInfo class is created?
Dim Dir As IEnumerable(Of FileInfo) =
From datei In Directory.EnumerateFiles("E:\MP3\mp3_amazon", "*.*", SearchOption.AllDirectories).Where(
Function(dateiname)
Return dateiname.IndexOf("butter", StringComparison.CurrentCultureIgnoreCase) > -1
End Function
).Select(Of FileInfo)(
Function(dateiname)
Return New FileInfo(dateiname)
End Function
)
Duplicate of this question.
Summary: Windows API doesn't support it, so you have to detect this issue in code and work around it. Using the file's short name (8.3) may work.