I'm looking for a C# method that will return all files (in all sub-directories) in an Azure file share.
Have an example but it throws a run time error. I've tried the code example below which I got from here however it throws an exception.
I have pasted the code in here but if anyone has a method that walks the entrire Azure directory get gets files that would be great.
CloudFileDirectory dir = fclient.GetShareReference(share.ToString()).GetRootDirectoryReference();
foreach (IListFileItem file in dir.ListFilesAndDirectories()) //.Directory.ListFilesAndDirectories())
{
list_subdir(file);
}
And the method.
public static void list_subdir(IListFileItem list)
{
Console.WriteLine("subdir");
CloudFileDirectory fileDirectory = (CloudFileDirectory)list;
IEnumerable<IListFileItem> fileList = fileDirectory.ListFilesAndDirectories();
foreach (IListFileItem listItem in fileList)
{
if (listItem.GetType() == typeof(Microsoft.WindowsAzure.Storage.File.CloudFileDirectory))
{
list_subdir(listItem);
}
else
{
Console.WriteLine(listItem.Uri.Segments.Last());
}
}
}
" at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.d__11.MoveNext()
in C:Program Files (x86)Jenkinsworkspacedotnet-split-pr-masterLibClassLibraryCommonCoreExecutorExecutor.cs:line 82
--- End of stack trace from previous location where exception was thrown ---
at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
at Microsoft.WindowsAzure.Storage.Core.Executor.Executor.<>c__DisplayClass0_0
1.b__0() in
C:Program Files (x86)Jenkinsworkspacedotnet-split-pr-masterLibClassLibraryCommonCoreExecutorExecutor.cs:line 41
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…