Azure file storage, get files in a sorted order

Question Status

Suggested Answer
David@Tridea asked a question on 6 Oct 2017 12:02 PM

I have an application that is reading files from an Azure file share.
This returns in file name order. How can I modify it to sort a different field like CreatedDate?   

So that the enumerator, when read is in the correct order.

             // Get a reference to the root directory for the share.
                CloudFileDirectory      rootDirectory   = fileShare.GetRootDirectoryReference();
                  
                // Get a reference to the directory we created previously.
                CloudFileDirectory      sampleDir = rootDirectory.GetDirectoryReference(scanFilePath);                          

                var     files = sampleDir.ListFilesAndDirectories(null, null); // System.Collections.Generic.IEnumerable`1;
                   
                var     enumerator  = files.getEnumerator();
                while (enumerator.moveNext())
                {
                    var  currentFile = enumerator.Current as CloudFile;
  }

Reply
Suggested Answer
ievgen Miroshnikov responded on 6 Oct 2017 10:20 PM

Hi David@Tridea,

ListFilesAndDirectories returns IEnumerable that could be easily sorted msdn.microsoft.com/.../bb534966(v=vs.110).aspx , however, AX does not support generics, linq and other stuff, so its better to write all the code using c sharp and then consume it as a reference in x++ instead of using CloudFileDirectory  directly

Reply
Suggested Answer
ievgen Miroshnikov responded on 6 Oct 2017 10:20 PM

Hi David@Tridea,

ListFilesAndDirectories returns IEnumerable that could be easily sorted msdn.microsoft.com/.../bb534966(v=vs.110).aspx , however, AX does not support generics, linq and other stuff, so its better to write all the code using c sharp and then consume it as a reference in x++ instead of using CloudFileDirectory  directly

Reply