iTunes 有轨道的旧位置(不再存在的文件路径)!在他们面前。我知道这一点,因为如果您右键单击轨道!在它前面并选择 GetInfo(然后选择否,不定位它)。在摘要选项卡下,它有一个部分显示歌曲的路径(不工作)。当我尝试使用 iTumes COM 获取轨道位置时,IITFileOrCDTrack.location 返回空字符串。那么,如何从 Getinfo --> Summary 选项卡中获取这个“where”值?
下面是我目前尝试获取轨道位置的方法(使用 C#)。我的整个 iTunes 库有 10 首歌曲,它们都指向错误的文件位置,所以我选择哪首歌曲都没有关系。
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.
最佳答案
当找到文件时,“where”值显示 C:\...
但当找不到文件时,它显示 file:\\C:\.. .
在 iTunes 中,从代码中,您可以使用 Location 属性访问位置(您的代码可能存在错误 - 将“Location”中的“L”大写)
来自 SDK 文档:
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
The operation was successful.
S_FALSE
The location could not be retrieved (e.g. no file exists at the expected location).
E_POINTER
location isNULL
.
ITUNES_E_OBJECTDELETED
This track has been deleted.
E_FAIL
An unexpected error occurred.
我能够重现这个(即当找不到文件时,在 iTunes 中查看“where”值,并从 IITFileOrCDTrack.Location 返回 null。我不认为它是除非未记录,否则如果找不到实际文件,则无法返回该值。
关于c# - iTunes COM。如何使用 C# 获取轨道的旧位置?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/4834419/