我正在关注 Azure 文档 here,它对代码示例感到困惑,目前我看到 sampleFilePath
、SampleFileContent
的错误“他们在这种情况下不存在”,他们没有记录...
// Append data to the DataLake File
file.Append(File.OpenRead(sampleFilePath), 0);
file.Flush(SampleFileContent.Length);
// Reading Data from a DataLake File
Response<FileDownloadInfo> fileContents = file.Read();
// Listing/Traversing through a DataLake Filesystem
foreach (PathItem pathItem in filesystem.GetPaths())
{
names.Add(pathItem.Name);
}
sampleFilePath
的位置?答案 0 :(得分:0)
sampleFilePath
只是一个文件路径,您可以在本地创建一个文件,然后将文件路径传递给它。像这样的代码:
DataLakeFileSystemClient filesystem = serviceClient.GetFileSystemClient(Randomize("sample-filesystem"));
filesystem.Create();
DataLakeDirectoryClient directory = filesystem.GetDirectoryClient(Randomize("sample-file"));
directory.Create();
DataLakeFileClient file = directory.GetFileClient(Randomize("sample-file"));
file.Create();
string sampleFilePath = "D:\\test\\test.txt";
FileStream SampleFileContent = File.OpenRead(sampleFilePath);
// Append data to the DataLake File
file.Append(File.OpenRead(sampleFilePath), 0);
file.Flush(SampleFileContent.Length);
// Reading Data from a DataLake File
Response<FileDownloadInfo> fileContents = file.Read();