Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/csharp/294.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文件共享属性LastModified的空值_C#_Azure_Azure Files - Fatal编程技术网

C# Azure文件共享属性LastModified的空值

C# Azure文件共享属性LastModified的空值,c#,azure,azure-files,C#,Azure,Azure Files,但是sourceName.Properties.LastModified为null 甚至fileShare.Properties.LastModified为空 当我试图获取Azure文件共享的LastModified属性时,我的值变为null。原因是每次调用GetRootDirectoryReference()时,您都会创建FileItem的新实例,导致其属性初始化为默认值,与使用GetBlockBlobReference()时的行为相同 您需要做的是调用FetchAttributes,以填充所

但是
sourceName.Properties.LastModified为null

甚至
fileShare.Properties.LastModified为空


当我试图获取Azure文件共享的LastModified属性时,我的值变为null。

原因是每次调用
GetRootDirectoryReference()
时,您都会创建
FileItem
的新实例,导致其属性初始化为默认值,与使用
GetBlockBlobReference()时的行为相同

您需要做的是调用
FetchAttributes
,以填充所有属性

请注意,获取属性时,不需要创建对象的新实例

您可以遵循这一点,即引用blob,但也关注您的错误


您要求的示例如下:

  // Get list of all files/directories on the file share 
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["storageConnectionString"]);
            CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient();
            CloudFileShare fileShare = fileClient.GetShareReference(ConfigurationManager.AppSettings["shareName"]);

            var sourceName = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings["sourceName"]));

            var test = sourceName.Properties.LastModified;

您可以在上阅读更多信息。

原因是每次调用
GetRootDirectoryReference()
时,您都会创建一个
FileItem
的新实例,导致其属性初始化为其默认值,这与使用
GetBlockBlobReference()
时的行为相同

您需要做的是调用
FetchAttributes
,以填充所有属性

请注意,获取属性时,不需要创建对象的新实例

您可以遵循这一点,即引用blob,但也关注您的错误


您要求的示例如下:

  // Get list of all files/directories on the file share 
            CloudStorageAccount cloudStorageAccount = CloudStorageAccount.Parse(ConfigurationManager.AppSettings["storageConnectionString"]);
            CloudFileClient fileClient = cloudStorageAccount.CreateCloudFileClient();
            CloudFileShare fileShare = fileClient.GetShareReference(ConfigurationManager.AppSettings["shareName"]);

            var sourceName = fileShare.GetRootDirectoryReference().GetDirectoryReference((ConfigurationManager.AppSettings["sourceName"]));

            var test = sourceName.Properties.LastModified;

您可以在上阅读更多信息。

非常感谢:)我也可以使用下面的查询来获取子文件夹上次更新的文件吗?var latest=fileShare.GetRootDirectoryReference().ListFilesAndDirectories().OfType().OrderByDescending(m=>m.Properties.LastModified).ToList().First();我有另外一个问题,你可以帮助我,我想请帮助我uu是的,我相信你可以,我会尽力帮助:)非常感谢哦,我刚刚注意到,我刚刚上传了一个新文件到那个文件夹,但最后修改的仍然是旧的日期,这意味着LastModified对于该文件夹和文件是分开的:O现在要做什么?我想检查是否有任何新文件在24小时内更新到主文件夹的任何子文件夹中。我们可以使用我在问题中提到的任何linq查询吗?非常感谢:)我也可以使用下面的查询来获取子文件夹上次更新的文件吗?var latest=fileShare.GetRootDirectoryReference().ListFilesAndDirectories().OfType().OrderByDescending(m=>m.Properties.LastModified).ToList().First();我有另外一个问题,你可以帮助我,我想请帮助我uu是的,我相信你可以,我会尽力帮助:)非常感谢哦,我刚刚注意到,我刚刚上传了一个新文件到那个文件夹,但最后修改的仍然是旧的日期,这意味着LastModified对于该文件夹和文件是独立的:O现在该怎么办?我想检查是否有任何新文件在24小时内更新到主文件夹的任何子文件夹中。我们可以使用我提到的任何linq查询吗?