![](/img/trans.png)
[英]Azure Data Lake Gen2 - How do I move files from folder to another folder using C#
[英]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.