public void UpdateFile(string folder, string file, byte[] data) { JObject card = cardarray.Children <JObject>() .FirstOrDefault(o => o["name"].ToString() == folder); if (card == null) { throw new Exception("資料夾不存在"); } JArray list = JArray.Parse( TrelloHelper.GetCardAttachmentList(_key, _token, card["id"].Value <string>())); // file list JObject attachment = list.Children <JObject>() .FirstOrDefault(o => o["name"].ToString() == file); // 已存在,刪除檔案 if (attachment != null) { TrelloHelper.DeleteAttachment(_key, _token, card["id"].Value <string>(), attachment["id"].Value <string>()); } TrelloHelper.CreateAttachment(_key, _token, card["id"].Value <string>(), file, data); }
public void DeleteFile(string folder, string file) { JObject card = cardarray.Children <JObject>() .FirstOrDefault(o => o["name"].ToString() == folder); if (card == null) { throw new Exception("資料夾不存在"); } // fetch file list JArray list = JArray.Parse( TrelloHelper.GetCardAttachmentList(_key, _token, card["id"].Value <string>())); JObject attachment = list.Children <JObject>() .FirstOrDefault(o => o["name"].ToString() == file); if (attachment == null) { throw new Exception("檔案不存在"); } TrelloHelper.DeleteAttachment(_key, _token, card["id"].Value <string>(), attachment["id"].Value <string>()); }