我需要從安全鏈接下載xml文件,並將內容存儲到數據庫中。如何處理下載流
我可以使用文本閱讀器?或者我需要先將文件存儲到本地文件系統中,然後從我的文件系統讀取內容並存儲到我的數據庫中?
HttpWebRequest downloadRequest = (HttpWebRequest)WebRequest.Create("https://line-to-xml-file.xml");
string Content;
downloadRequest.Credentials = new NetworkCredential()
{
UserName = this._userCredentials.UserName,
Password = this._userCredentials.Password
};
downloadRequest.PreAuthenticate = true;
using (HttpWebResponse downloadHTTPResponse = (HttpWebResponse)downloadRequest.GetResponse())
{
using (Stream downloadResponseStream = downloadHTTPResponse.GetResponseStream())
using (TextReader tReader = new StreamReader(downloadResponseStream))
{
Content = tReader.ReadToEnd();
}
}
return Content;
由於遠程文件很大,高達100MB,所以我從調試中什麼都看不到。 當我嘗試保存它。
using (TransactionScope trans = new TransactionScope()) <--- when comes to this line, exception throws...
{
// perform update, save the content into databse
// send a notification message to message bus, indicate content has been updated
}
它抱怨MSDTC事務超時/取消