【问题标题】:Read file from Azure into MemoryStream C#将文件从 Azure 读入 MemoryStream C#
【发布时间】:2020-01-08 02:39:22
【问题描述】:

我在 Azure 上有一个 ini 配置文件。我不想下载这个文件,这是它目前的处理方式。我想将它读入 MemoryStream 并从那里解析它,然后让 MemoryStream 自动刷新数据。

有什么方法可以做到这一点,而不必将文件本身下载到本地驱动器上?

目前的下载方式是:

    myWebClient.DownloadFile("AzureLink", @"C:\\Program Files (x86)\\MyProgram\\downloadedFile.ini")

【问题讨论】:

  • 你现在下载的代码是什么?
  • 请告诉我们您目前是如何执行下载的。
  • 艾米和坦维尔,我已经更新了原帖
  • myWebClient 的类型?在我看来HttpClient
  • 我猜是WebClient,OP只需要切换到DownloadData()

标签: c# azure


【解决方案1】:

我想这就是你要找的东西:

WebClient wc = new WebClient();
using (MemoryStream stream = new MemoryStream(wc.DownloadData(url))) 
{
    //your code in here
}

【讨论】:

    猜你喜欢
    • 2022-01-19
    • 2013-02-06
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2011-07-17
    • 2020-02-04
    相关资源
    最近更新 更多