public async Task Sample01b_HelloWorldAsync_TraverseAsync() { // Create a temporary Lorem Ipsum file on disk that we can upload string originalPath = CreateTempFile(SampleFileContent); // Get a reference to a share named "sample-share" and then create it string shareName = Randomize("sample-share"); ShareClient share = new ShareClient(ConnectionString, shareName); await share.CreateAsync(); try { // Create a bunch of directories ShareDirectoryClient first = await share.CreateDirectoryAsync("first"); await first.CreateSubdirectoryAsync("a"); await first.CreateSubdirectoryAsync("b"); ShareDirectoryClient second = await share.CreateDirectoryAsync("second"); await second.CreateSubdirectoryAsync("c"); await second.CreateSubdirectoryAsync("d"); await share.CreateDirectoryAsync("third"); ShareDirectoryClient fourth = await share.CreateDirectoryAsync("fourth"); ShareDirectoryClient deepest = await fourth.CreateSubdirectoryAsync("e"); // Upload a file named "file" ShareFileClient file = deepest.GetFileClient("file"); using (FileStream stream = File.OpenRead(originalPath)) { await file.CreateAsync(stream.Length); await file.UploadRangeAsync( ShareFileRangeWriteType.Update, new HttpRange(0, stream.Length), stream); } await Sample01b_HelloWorldAsync.TraverseAsync(ConnectionString, shareName); } finally { await share.DeleteAsync(); } }
public static async Task CreateSubDirectory(string account, string key, string share, string folder, string subDir) { ShareDirectoryClient parentDir = GetShareDirectoryClient(account, key, share, folder); await parentDir.CreateSubdirectoryAsync(subDir); }