/// <summary>
        /// Put Range Request
        /// </summary>
        /// <returns></returns>
        public async Task PutRangeAsync(Uri storageUri, byte[] bytes, int startBytes = 0, string writeMode = "Update")
        {
            if (string.IsNullOrEmpty(storageUri.Query) || !storageUri.Query.Contains("comp=range"))
            {
                throw new Exception("Missing Query String comp=range");
            }

            using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, storageUri))
            {
                httpRequestMessage.Content = new ByteArrayContent(bytes);

                var contentlength = httpRequestMessage.Content.Headers.ContentLength - 1;

                var now = DateTime.UtcNow;
                SetDefaultHeaders(httpRequestMessage, now);

                httpRequestMessage.Headers.Add("x-ms-range", $"bytes={startBytes}-{contentlength.ToString()}");
                httpRequestMessage.Headers.Add("x-ms-write", writeMode);

                // Add the authorization header.
                httpRequestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
                    storageAccountName, storageAccountKey, now, httpRequestMessage);

                using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))
                {
                    if (httpResponseMessage.StatusCode == HttpStatusCode.Created)
                    {
                        var response = await httpResponseMessage.Content.ReadAsStringAsync();
                    }
                }
            }
        }
        public async Task <bool> CreateFileAsync(string storageUri, int contentLength)
        {
            //Instantiate the request message with a empty payload.
            using (var httpRequestMessage =
                       new HttpRequestMessage(HttpMethod.Put, storageUri)
            {
                Content = new StringContent("")
            })
            {
                var now = DateTime.UtcNow;

                SetDefaultHeaders(httpRequestMessage, now);
                // Required. This header specifies the maximum size for the file, up to 1 TiB.
                httpRequestMessage.Headers.Add("x-ms-content-length", contentLength.ToString());
                httpRequestMessage.Headers.Add("x-ms-type", "file");

                // If you need any additional headers, add them here before creating
                //   the authorization header.

                // Add the authorization header.
                httpRequestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
                    storageAccountName, storageAccountKey, now, httpRequestMessage);

                using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))
                {
                    if (httpResponseMessage.StatusCode == HttpStatusCode.Created)
                    {
                        var response = await httpResponseMessage.Content.ReadAsStringAsync();

                        return(true);
                    }
                }
                return(false);
            }
        }
        public async Task <IFile> GetFile(string directory, string fileName)
        {
            // Construct the URI. This will look like this:
            //   https://myaccount.blob.core.windows.net/resource
            String uri = $"https://{storageAccountName}.file.core.windows.net/{rootDirectory}/{directory}/{fileName}";

            // Set this to whatever payload you desire. Ours is null because
            //   we're not passing anything in.
            Byte[] responsePayload = null;

            //Instantiate the request message with a null payload.
            using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri))
            {
                // Add the request headers for x-ms-date and x-ms-version.
                DateTime now = DateTime.UtcNow;
                SetDefaultHeaders(httpRequestMessage, now);
                // If you need any additional headers, add them here before creating
                //   the authorization header.

                // Add the authorization header.
                httpRequestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
                    storageAccountName, storageAccountKey, now, httpRequestMessage);

                // Send the request.
                using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))
                {
                    // If successful (status code = 200),
                    //   parse the XML response for the container names.
                    if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                    {
                        var fileContent = await httpResponseMessage.Content.ReadAsByteArrayAsync();

                        var file = new File
                        {
                            Directory     = directory,
                            Name          = fileName,
                            ContentLength = fileContent.Length
                        };
                        file.AddDataContent(fileContent);
                        return(file);
                    }
                }
                return(null);
            }
        }
        public async Task CreateDirectory(string directoryName)
        {
            // Construct the URI. This will look like this:
            //   https://myaccount.blob.core.windows.net/resource
            String uri = $"https://{storageAccountName}.file.core.windows.net/{rootDirectory}/{directoryName}?restype=directory";

            //Instantiate the request message with a null payload.
            using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Put, uri))
            {
                // Add the request headers for x-ms-date and x-ms-version.
                DateTime now = DateTime.UtcNow;
                SetDefaultHeaders(httpRequestMessage, now);
                // If you need any additional headers, add them here before creating
                //   the authorization header.

                // Add the authorization header.
                httpRequestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
                    storageAccountName, storageAccountKey, now, httpRequestMessage);

                // Send the request.
                using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))
                {
                    // If successful (status code = 200),
                    //   parse the XML response for the container names.
                    if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                    {
                        String xmlString = await httpResponseMessage.Content.ReadAsStringAsync();

                        XElement x = XElement.Parse(xmlString);
                        foreach (XElement container in x.Element("Shares").Elements("Share"))
                        {
                        }
                    }
                }
            }
        }
        public async Task <IEnumerable <IFileMetadata> > ListAll(string directory = "")
        {
            var items = new List <IFile>();

            string subDirectory = !string.IsNullOrEmpty(directory) ? $"/{directory}" : string.Empty;
            // Construct the URI. This will look like this:
            //   https://myaccount.blob.core.windows.net/resource
            String uri = $"https://{storageAccountName}.file.core.windows.net/{rootDirectory}{subDirectory}?restype=directory&comp=list";

            // Set this to whatever payload you desire. Ours is null because
            //   we're not passing anything in.
            Byte[] requestPayload = null;

            //Instantiate the request message with a null payload.
            using (var httpRequestMessage = new HttpRequestMessage(HttpMethod.Get, uri)
            {
                Content = (requestPayload == null) ? null : new ByteArrayContent(requestPayload)
            })
            {
                // Add the request headers for x-ms-date and x-ms-version.
                DateTime now = DateTime.UtcNow;
                SetDefaultHeaders(httpRequestMessage, now);
                // If you need any additional headers, add them here before creating
                //   the authorization header.

                // Add the authorization header.
                httpRequestMessage.Headers.Authorization = AzureStorageAuthenticationHelper.GetAuthorizationHeader(
                    storageAccountName, storageAccountKey, now, httpRequestMessage);

                // Send the request.
                using (HttpResponseMessage httpResponseMessage = await new HttpClient().SendAsync(httpRequestMessage))
                {
                    // If successful (status code = 200),
                    //   parse the XML response for the container names.
                    if (httpResponseMessage.StatusCode == HttpStatusCode.OK)
                    {
                        String xmlString = await httpResponseMessage.Content.ReadAsStringAsync();

                        XElement x = XElement.Parse(xmlString);

                        if (x.Attribute("DirectoryPath") != null)
                        {
                            items.Add(new File {
                                Directory = x.Attribute("DirectoryPath").Value
                            });
                        }

                        foreach (XElement container in x.Elements("Entries"))
                        {
                            foreach (XElement dir in container.Elements("Directory"))
                            {
                                var name = dir.Value;
                                items.Add(new File {
                                    Directory = name
                                });
                            }

                            foreach (XElement file in container.Elements("File"))
                            {
                                var name = file.Value;
                                items.Add(new File {
                                    Directory = directory, Name = name
                                });
                            }
                        }
                    }
                }
            }

            return(items);
        }