I am new to c# and asp.net. I am trying to save an image in a default location without giving the path. Currently I dont know how to do this.
This is my function:
[HttpGet]
[Route("GetImages")]
public async Task<IHttpActionResult> GetImagesAsync()
{
ServicePointManager.SecurityProtocol = SecurityProtocolType.Tls12;
WebProxy myproxy = new WebProxy("corpproxy1.tatasteel.com", 80);
myproxy.BypassProxyOnLocal = false;
//myproxy.UseDefaultCredentials = true;
HttpClientHandler handler = new HttpClientHandler()
{
Proxy = myproxy
};
using (var client = new HttpClient(handler))
{
var bytes = await
client.GetByteArrayAsync("https://firebasestorage.googleapis.com/v0/b/tsl-
coil-qlty-monitoring-dev.appspot.com/o/1a60ce3b-eddf-4e72-b2af-b6e99873e926?
alt=media&token=61399a02-1009-4bb9-ad89-d1235df900e4");
var bytes_image = Convert.ToBase64String(bytes);
byte[] bitmap = bytes;
using (Image image = Image.FromStream(new MemoryStream(bitmap)))
{
image.Save("D:\\CQMS_Images_JPEG\\output.png", ImageFormat.Png); // Or
Png
return Ok(image);
}
}
I do not want to give a path like this
image.Save("D:\\CQMS_Images_JPEG\\output.png", ImageFormat.Png);
I want it to store in a default location maybe me just giving this path name as in:
Or store it in the root folder. This Application will be used for mobiles as well hence the requirement
image.Save("output.png", ImageFormat.Png);
How do I do this Please help??