public static bool DeleteFileContent(string filePath, string fileName) { bool IsFileDeleted = false; try { string url = System.Web.Configuration.WebConfigurationManager.AppSettings["AzureStorageServiceUrl1"] + "?filePath=" + filePath + "" + "&fileName=" + fileName; HttpWebRequest getRequest = (HttpWebRequest)HttpWebRequest.Create(url); getRequest.Method = "DELETE"; // add authorization header to request header.. ExigentServiceHelper.SetBasicAuthHeader(getRequest); var getResponse = (HttpWebResponse)getRequest.GetResponse(); if (getResponse.StatusCode == HttpStatusCode.OK) { using (Stream respStream = getResponse.GetResponseStream()) { var reader = new StreamReader(respStream, Encoding.ASCII); string responseText = reader.ReadToEnd(); reader.Close(); IsFileDeleted = Convert.ToBoolean(responseText); } } } catch (Exception ex) { throw new Exception(ex.Message); } return(IsFileDeleted); }
public static byte[] GetFileContent(string fileUrl) { byte[] fileContent = null; try { string responseText = string.Empty; if (!string.IsNullOrEmpty(fileUrl)) { string url = ConfigurationManager.AppSettings["AzureStorageServiceUrl1"] + "?imagePath=" + fileUrl; var azmblRequest = (HttpWebRequest)WebRequest.Create(url); azmblRequest.Method = "GET"; // add authorization header to request header.. ExigentServiceHelper.SetBasicAuthHeader(azmblRequest); var getResponse = (HttpWebResponse)azmblRequest.GetResponse(); if (getResponse.StatusCode == HttpStatusCode.OK) { using (Stream respStream = getResponse.GetResponseStream()) { var reader = new StreamReader(respStream, Encoding.ASCII); responseText = reader.ReadToEnd(); if (!string.IsNullOrEmpty(responseText)) { responseText = responseText.Replace("\"", ""); fileContent = System.Text.Encoding.ASCII.GetBytes(responseText); } reader.Close(); } } } } catch (Exception ex) { throw new Exception(ex.Message); } finally { } return(fileContent); }