我需要从安全链接下载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事务超时/取消