Create and Delete directory In Azure File Storage at run time. RRS feed

  • Question

  • I need to create & delete directories Using c# script in Azure file storage at run time. 

    Directory to be  created under: Storage/Share/Directory1/Directory2.

    Appreciate assistance for this. This is what i have so far:

    // Parse the connection string and return a reference to the storage account.
                CloudStorageAccount storageAccount = CloudStorageAccount.Parse(
                // Create a CloudFileClient object for credentialed access to File storage.
                CloudFileClient fileClient = storageAccount.CreateCloudFileClient();
                // Get a reference to the file share we created previously.
                CloudFileShare share = fileClient.GetShareReference("dev");
                // Ensure that the share exists.
                if (share.Exists())
                    // Get a reference to the root directory for the share.
                    CloudFileDirectory rootDir = share.GetRootDirectoryReference();
                    // Get a reference to the directory we created previously.
                    CloudFileDirectory sampleDir = rootDir.GetDirectoryReference("DIR");
                    // Ensure that the directory exists.
                    if (sampleDir.Exists())
                        // Get a reference to the file we created previously.
                        CloudFile file = sampleDir.GetFileReference("Log1.txt");
                        // Ensure that the file exists.
                        if (file.Exists())
                            // Write the contents of the file to the console window.

    Thanks, Nilesh

    Tuesday, April 26, 2016 6:30 AM

All replies