我需要使用新包 Azure.Storage.Blobs 从 Azure 存储中获取字节数组格式的文件。我无法找到在 C# 中执行此操作的方法。
public byte[] GetFileFromAzure()
{
byte[] filebytes;
BlobServiceClient blobServiceClient = new BlobServiceClient( "TestClient");
BlobContainerClient containerClient = blobServiceClient.GetBlobContainerClient("TestContainer");
BlobClient blobClient = containerClient.GetBlobClient("te.xlsx");
if (blobClient.ExistsAsync().Result)
{
var response = blobClient.DownloadAsync().Result;
using (var streamReader = new StreamReader(response.Value.Content))
{
var line = streamReader.ReadToEnd();
//No idea how to convert this to ByteArray
}
}
return filebytes;
}
Run Code Online (Sandbox Code Playgroud)
知道如何实现获取存储在 Azure Blob 存储上的文件字节数组吗?
感谢帮助。
我在C#中有几个.NET应用程序,以及一个用于访问数据库的API.我想将所有版本的API放在数据库中,让他们选择最高版本和内部版本号,但要坚持使用它们构建的主要和次要编号.基本上,当我引用API时,1.2.3.4我希望引用读取,1.2.*.*以便应用程序只需要提取,1.2.3.5我看到我可以使用XML配置文件执行此操作.我宁愿让它遵守.类似于发布策略,但没有额外的文件.我可以满足于此.另一个问题是我看到的所有解决方案都将一个版本重定向到另一个特定版本,而不仅仅是更新版本.
我该怎么做呢?
有人能指出我对出版商政策的信息来源吗?
在使用 VS config 添加新配置后尝试调用类的GetDatabase方法时,我收到以下异常MongoClient。经理:
Could not load file or assembly 'System.Buffers, Version=4.0.2.0, Culture=neutral, PublicKeyToken=cc7b13ffcd2ddd51' or one of its dependencies. The located assembly's manifest definition does not match the assembly reference. (Exception from HRESULT: 0x80131040)
Run Code Online (Sandbox Code Playgroud)
我安装了最新的 System.Buffer nuget 包 v4.5.1,在我的 app.config 中创建了dependentAssembly,在我的 .csproj 文件中创建了 Reference,但我仍然有同样的问题。出于某种原因,它尝试使用 v4.0.2 引用 System.Buffer。有没有人遇到过类似的错误,你是如何解决的?
我们在一些新的类库中使用Microsoft的Unity框架进行依赖注入.主应用程序正在使用一些期望Unity v2.0.414的其他企业库(通用和日志),但我们使用Unity v2.1.515实现了我们的库.
为了解决版本差异,我为主应用程序创建了一个app.Config,并将一个bindingRedirect条目放入配置文件中并且运行良好.然而,我们刚刚了解到应用程序到目前为止从未使用过app.config,而mgmt更喜欢这种方式.
那么有可能以编程方式实现程序集重定向(即在代码中)吗?谢谢!