title: how to search matching data in latest file using azure search in blob container c#
body: <p>I have azure blob container named <code>dataTest</code> inside that have <code>multiple folders created based on year/ month / date.</code></p>
  
  <pre><code>dataTest/rawjson/2019/01/25/01/demo1.json
  
  dataTest/rawjson/2018/12/30/02/demo2.json
  </code></pre>
  
  <p>I want to get the file from latest folder path would be-</p>
  
  <pre><code>dataTest/rawjson/2019/01/25/01/demo1.json
  </code></pre>
  
  <p>How do I get the latest path <code>(dataTest/rawjson/2019/01/25/01/demo1.json)</code></p>
  
  <p>when I pass input as <code>dataTest/rawjson</code> </p>
  
  <p>I want to read data using <code>azure search</code> we need to create a <code>index</code> by importing this blob container.</p>
  
  <p>I wonder is there any way to pass this blob path dynamically and get the latest file data using <code>azure search</code>?</p>
  
  <p>before <code>azure search</code> i was using below c# code to get latest file </p>
  
  <pre><code>CloudBlobClient blobClient = storageAccount.CreateCloudBlobClient();
              CloudBlobContainer container = blobClient.GetContainerReference("dataTest");
  
              string directoryreference = "dataTest/rawjson/events";
  
              var blobDirectory = container.GetDirectoryReference(directoryreference);
              IEnumerable&lt;IListBlobItem&gt; items = blobDirectory.ListBlobs(useFlatBlobListing: true);
  
              string blobFilePath = String.Empty;
              foreach (var blob in items.OfType&lt;CloudBlob&gt;()
  
      .OrderByDescending(b =&gt; b.Properties.LastModified))
              {
                  string blobFileFullPath = Path.GetDirectoryName(blob.Name).Replace("\\", "/");
                  blobFilePath = Path.GetDirectoryName(blobFileFullPath).Replace("\\", "/");
                  if (blobFilePath != null)
                  { break; }
  
              }
              var blobFileDirectory = container.GetDirectoryReference(blobFilePath);
              IEnumerable&lt;IListBlobItem&gt; fileitems = blobFileDirectory.ListBlobs(useFlatBlobListing: true);
  </code></pre>