1

我想显示存储帐户中的所有文件共享。我有存储帐户下拉菜单,因此每当用户选择特定的存储帐户名称时,我都想获取与所选存储帐户关联的所有文件共享名称。我想要任何 Fluent API 或 REST API。

4

1 回答 1

1
using System;
using System.Threading.Tasks;
using Azure.Storage.Files.Shares;
using Azure.Storage.Files.Shares.Models;

namespace ConsoleApp5
{
    class Program
    {
        static async Task Main(string[] args)
        {
            Console.WriteLine("xxxxxxxxxxxxxxxxxxxxx");
            string connectionString = "DefaultEndpointsProtocol=https;AccountName=0730bowmanwindow;AccountKey=xxxxxx;EndpointSuffix=core.windows.net";

            ShareServiceClient ssc = new ShareServiceClient(connectionString);
            foreach (ShareItem item in ssc.GetShares())
            {
                Console.WriteLine(item.Name);
            }

        }
    }
}

这是 REST API:

https://docs.microsoft.com/en-us/rest/api/storageservices/list-shares

.csproj

<Project Sdk="Microsoft.NET.Sdk">

  <PropertyGroup>
    <OutputType>Exe</OutputType>
    <TargetFramework>netcoreapp3.1</TargetFramework>
  </PropertyGroup>

  <ItemGroup>
    <PackageReference Include="Azure.Storage.Files.Shares" Version="12.6.2" />
  </ItemGroup>

</Project>
于 2021-06-02T10:31:55.567 回答