我想通过将文件扩展名作为参数传递给方法来获取多媒体类型的 TCM URI。以下是我正在使用的代码,但出现了一些异常:-
private static string GetMultimediaTypeTCMURI(FileExtensionsList lFileExtensions)
{
string lTCMURI = "";
try
{
SessionAwareCoreService2010Client client
= new SessionAwareCoreService2010Client();
client.ClientCredentials.Windows.ClientCredential.UserName = "myUserName";
client.ClientCredentials.Windows.ClientCredential.Password = "myPassword";
client.Open();
FileExtensionsList list = new FileExtensionsList();
var mmType = client.GetSystemWideList(new MultimediaTypesFilterData())
.Single(mt => ((MultimediaTypeData)mt).FileExtensions == lFileExtensions);
lTCMURI = mmType.Id;
}
catch (Exception e)
{
throw new Exception("Please check either Mimetype"
+ lFileExtensions + "is wrong or Mimetype does not exist in SDL Tridion.");
}
return lTCMURI;
}
调用上述方法:-
FileExtensionsList list = new FileExtensionsList();
list.Add("js");
GetMultimediaTypeTCMURI(list);
我在上面的代码中收到“序列不包含匹配元素”异常,请任何人建议如何执行此操作。