本文整理汇总了C#中Request.Download方法的典型用法代码示例。如果您正苦于以下问题:C# Request.Download方法的具体用法?C# Request.Download怎么用?C# Request.Download使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类Request
的用法示例。
在下文中一共展示了Request.Download方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: DoFileDownload
private void DoFileDownload(Request documentsRequest, ITaskItem document, string targetFile)
{
using (Stream downloadStream = documentsRequest.Download(document, ExportFormat))
using (FileStream fileSaveStream = new FileStream(targetFile, FileMode.OpenOrCreate))
{
downloadStream.CopyTo(fileSaveStream);
}
}
示例2: DoDocumentHtmlDownload
private void DoDocumentHtmlDownload(Request documentsRequest, ITaskItem document, string targetFile)
{
using (Stream downloadStream = documentsRequest.Download(document, Document.DownloadType.html))
using (FileStream fileSaveStream = new FileStream(targetFile, FileMode.OpenOrCreate))
using (StreamWriter streamWriter = new StreamWriter(fileSaveStream))
using (StreamReader streamReader = new StreamReader(downloadStream))
{
streamWriter.WriteLine("<!DOCTYPE html PUBLIC \"-//W3C//DTD XHTML 1.0 Transitional//EN\"");
streamWriter.WriteLine("\"http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd\">");
while (!streamReader.EndOfStream)
{
string line = streamReader.ReadLine();
if (line.Contains('&'))
{
foreach (var pair in _HtmlEntityReplacements)
{
line = line.Replace(pair.Key, string.Format("<xm:ent code=\"{0}\"/>", pair.Value));
}
}
streamWriter.WriteLine(line);
}
}
}