2016-08-22 77 views
1

我試圖訪問用戶發送到我正在開發的skype機器人的附件列表。在Skype bot框架附件內容null

這裏是我訪問附件的詳細信息,

 public async Task<HttpResponseMessage> Post([FromBody]Activity message) 
    { 

     if (message.Attachments != null) 
     { 
      if (message.Attachments.Count > 0) 
      { 
       List<Attachment> attachmentList = message.Attachments.ToList(); 

       foreach (var item in attachmentList) 
       { 
        var name = item.Name; 
        var content = item.Content; 
       } 
      } 
     } 
    } 

,但我得到空以下,即使附件計數大於零,

var name = item.Name; 
    var content = item.Content; 

我這樣做對嗎?

+2

可能重複[上傳圖像到Skype BOT](http://stackoverflow.com/questions/38633676/upload-image-to-skype-bot) –

回答

-2

也許做這樣的事情......

List<Attachment> attachmentList = message?.Attachments?.Where(x => x != null)?.ToList() ?? new List<Attachment>(); 

這將有希望始終設置attachmentList空列表或包含非空項的列表?