繁体   English   中英

尝试将文件从 Azure Data Lake 文件夹移动到另一个

[英]Trying to move a file from a Azure Data Lake folder to another

我有功能应用程序从数据湖读取文件并对文件内容进行一些处理。 如果失败,则将文件移动到“错误”文件夹。 我试过这个但没有成功。 解决方案我试过SO-solution

public static async Task<DataLakeFileClient> MoveDirectory(string file)
{        
    DataLakeServiceClient serviceClient = await GetDataLakeClient(); 

    DataLakeFileSystemClient filesystemClient = 
    serviceClient.GetFileSystemClient(<CONTAINER>);
    
    DataLakeFileClient fileClient = 
    filesystemClient.GetFileClient("Provision/" + file);
    
    return await fileClient.RenameAsync("Provision/Error/" + file);
}

导致 404 SourcePathNotFound。

任何提示或建议如何将文件从一个目录移动到另一个目录?

进行一些更改后,我们可以完成这项工作。 在为所需文件使用 GetFileClient 时,您需要使用 DataLakeFileSystemClient 而不是 DataLakeServiceClient。 下面是对我有用的代码。

DataLakeServiceClient dataLakeServiceClient = new DataLakeServiceClient("<CONNECTION STRING>");
DataLakeFileSystemClient dataLakeFileSystemClient = dataLakeServiceClient.GetFileSystemClient("<CONTAINER>");

DataLakeFileClient sourceDataLakeFileClient = dataLakeFileSystemClient.GetFileClient("provision/<FILENAME>");
return await sourceDataLakeFileClient.RenameAsync("provision/Error/<FILENAME>");

结果:

执行前

在此处输入图像描述

执行后

在此处输入图像描述

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM