title: Move files between azure file share and blob
body: <p>I have to move some files between a share and a blob on the same storage account.
  After some googleing I ended up with this code:</p>
  
  <pre><code>CloudFileClient fileClient = account.CreateCloudFileClient();
  CloudFileShare share = fileClient.GetShareReference("shareName");
  CloudFileDirectory rootDir = share.GetRootDirectoryReference();
  CloudFileDirectory videoDirectory = rootDir.GetDirectoryReference(video.StoragePath);
  CloudBlobClient blobClient = account.CreateCloudBlobClient();
  CloudBlobContainer container = blobClient.GetContainerReference(video.StoragePath);
  container.CreateIfNotExists();
  
  foreach (var Files in videoDirectory.ListFilesAndDirectories())
  {
      var arr = Files.Uri.ToString().Split('/');
      string strFileName = arr[arr.Length - 1];
      CloudFile sourceFile = videoDirectory.GetFileReference(strFileName);
      string fileSas = sourceFile.GetSharedAccessSignature(new SharedAccessFilePolicy()
      {
          Permissions = SharedAccessFilePermissions.Read,
          SharedAccessExpiryTime = DateTime.UtcNow.AddHours(24)
      });
  
      Uri fileSasUri = new Uri(sourceFile.StorageUri.PrimaryUri.ToString() + fileSas);
  
      CloudBlockBlob blockBlob = container.GetBlockBlobReference(strFileName);
      blockBlob.StartCopyAsync(fileSasUri).Wait();    //copy the file to blob storage and wait for the operation to complete
      //sourceFile.DeleteAsync();    //delete the file  
  }
  //videoDirectory.DeleteAsync();    //delete the directory
  </code></pre>
  
  <p>If the delete lines are uncommented the destination contains all the files in the source folder but with 0 in size.</p>
  
  <p>Any ideas what am I doing wrong?</p>
  
  <p>I also want to delete the share directory after all the files are copied. Is there a way to check if the files are in the destination folder?</p>