Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/333.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
C# 访问Azure中的Blob属性_C#_Azure_Azure Storage Blobs - Fatal编程技术网

C# 访问Azure中的Blob属性

C# 访问Azure中的Blob属性,c#,azure,azure-storage-blobs,C#,Azure,Azure Storage Blobs,我需要得到blob属性,因为有一个最后修改的日期。我需要比较的日期。我读过很多文章,认为这是因为我没有使用CloudBlockBlob,但我无法从中提取属性 到目前为止,我的代码返回blob的名称: public static void ListBlobsAnonymously() { //Get the blob from the URL - URL is in the app.config file so it can be changed easily should

我需要得到blob属性,因为有一个最后修改的日期。我需要比较的日期。我读过很多文章,认为这是因为我没有使用CloudBlockBlob,但我无法从中提取属性

到目前为止,我的代码返回blob的名称:

public static void ListBlobsAnonymously()
    {
        //Get the blob from the URL - URL is in the app.config file so it can be changed easily should it need it. 
        CloudBlobContainer container = new CloudBlobContainer(new Uri(ConfigurationManager.AppSettings["VOURL"]));

        //For each of the blobs, write the file name out. This will be needed for a comparison. 
        foreach (IListBlobItem blobItem in container.ListBlobs())
        {
            string name = blobItem.Uri.Segments.Last();
            Console.WriteLine(name);
        }

        Console.ReadKey();
    }
<EnumerationResults ServiceEndpoint="https://test.blob.core.windows.net/" ContainerName="downloads">
<Blobs>
    <Blob>
        <Name>
        This_is_a_test
        </Name>
        <Properties>
            <Last-Modified>Tue, 01 Oct 2010 14:33:48 GMT</Last-Modified>
            <Content-Length>452</Content-Length>
            <Content-Type>application/zip</Content-Type>
            <BlobType>BlockBlob</BlobType>
        </Properties>
    </Blob>
</Blobs>
</EnumerationResults>
这是水滴的结构:

public static void ListBlobsAnonymously()
    {
        //Get the blob from the URL - URL is in the app.config file so it can be changed easily should it need it. 
        CloudBlobContainer container = new CloudBlobContainer(new Uri(ConfigurationManager.AppSettings["VOURL"]));

        //For each of the blobs, write the file name out. This will be needed for a comparison. 
        foreach (IListBlobItem blobItem in container.ListBlobs())
        {
            string name = blobItem.Uri.Segments.Last();
            Console.WriteLine(name);
        }

        Console.ReadKey();
    }
<EnumerationResults ServiceEndpoint="https://test.blob.core.windows.net/" ContainerName="downloads">
<Blobs>
    <Blob>
        <Name>
        This_is_a_test
        </Name>
        <Properties>
            <Last-Modified>Tue, 01 Oct 2010 14:33:48 GMT</Last-Modified>
            <Content-Length>452</Content-Length>
            <Content-Type>application/zip</Content-Type>
            <BlobType>BlockBlob</BlobType>
        </Properties>
    </Blob>
</Blobs>
</EnumerationResults>

这是一个测试
2010年10月1日星期二14:33:48 GMT
452
应用程序/zip
块状物
这是我需要掌握的属性中的最后一次修改,无法使用。

请尝试以下代码:(注意:不支持/使用NET Core)


基本上,您需要将
IListBlobItem
转换为
CloudBlob
,这样您就可以访问blob的属性。

试试blob.properties.lastModified使用上面的代码,我只能访问容器的属性,而不能访问blob本身,这是我认为问题的症结所在。因此,我可以获取container.Properties.LastModified,但我确实需要blobItem.Properties.LastModified,但我无法访问ListBlob的属性。“我可以获取属性,我需要属性,我无法获取属性”。这很令人困惑。请重新构造您的注释如果您查看我的代码,我将明确说明我可以和无法获取的属性。我有一个可以获取其属性的容器。我有一些无法获得其属性的斑点。这是我需要掌握的blob属性。不知道我怎么才能说得更清楚?你到底想要什么??财产?你明白了。除了你想要的东西和不能得到的东西之外,还有什么东西是我所缺少的,阅读了让我进入这条轨道的链接“这是一个陷阱”。感谢您抽出时间回复,非常感谢。很高兴我能提供帮助。如果解决了您的问题,请确保接受答案。platforms net core上缺少关于此ListBlobs的任何想法,因此替代方法可能是使用*Async重载。但是,请注意没有ListBlobsAsync,因为.NET中没有IEnumerable的异步对应项。因此,您应该调用ListBlobsSegmentedAsync并处理它返回的延续令牌。见下面的问题