ITunes COM. How to track old location using C #?

iTunes has the same place (path to a file that no longer exists) with the track! In front of them. I know this because if you right-click on a track! in front of it and select GetInfo (then select no, you will not find it). In the "Summary" section there is a section that shows the path to the song (does not work). when I try to get the track location using iTumes COM, IITFileOrCDTrack.location returns an empty string. So, how do I get the value of "where" in the Getinfo → Summary tab?

Below is an example of how I am trying to find the location of a track (using C #). All my iTunes lib has 10songs, all of them indicate the wrong file location, so it doesn't matter which song I chose.

iTunesApp itunes = new iTunesApp(); IITLibraryPlaylist mainLibrary = itunes.LibraryPlaylist; IITTrackCollection tracks = mainLibrary.Tracks; IITFileOrCDTrack currTrack; currTrack = tracks[5] as IITFileOrCDTrack; Console.WriteLine(currTrack.location) //output is blank. 
+4
source share
1 answer

When the file is found, the value "where" shows C:\... , but when the file is not found, it shows file:\\C:\... in iTunes, and from the code you can access the location using the Location property (error, possibly with your code - use "L" in "Location")

From the SDK documentation:

HRESULT Location ([out, retval] BSTR *location)

Returns the full path to the file represented by this track.

Parameters: location Returns the full path to the file represented by this track.

Return Values:

S_OK operation was successful.
S_FALSE location cannot be restored (for example, the file does not exist in the expected location).
E_POINTER location is NULL .
ITUNES_E_OBJECTDELETED This track has been deleted.
E_FAIL An unexpected error has occurred.

I was able to reproduce this (that is, see the value of "where" in itunes when the file cannot be found, and get the null returned from the IITFileOrCDTrack.Location file. I do not think that If this is undocumented, it is impossible to return the value if The actual file was not found.

+1
source

Source: https://habr.com/ru/post/1337559/


All Articles