3
我想通過將文件擴展名作爲參數傳遞給方法來獲取多媒體類型的TCM URI。下面是我使用的代碼,但我得到了一些異常: -如何通過文件擴展名獲取多媒體類型的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);
我得到「序列中沒有匹配的元素」異常以上代碼,任何人請建議如何做到這一點。
您的回覆回答我的問題,非常感謝。 –