I save a png file using savedialogfile. But I want to save it in application IMG folder. My code is as follows:
if (lastSnapshot != null)//writableBitmap object lastSnapshot
{
var dlg = new SaveFileDialog();
dlg.DefaultExt = ".png";
dlg.Filter = "PNG File|*.png";
if (dlg.ShowDialog() == true)
{
using (var pngStream = GetPngStream(lastSnapshot))//return Stream type
using (var file = dlg.OpenFile())
{
byte[] binaryData = new Byte[pngStream.Length];
long bytesRead = pngStream.Read(binaryData, 0, (int)pngStream.Length);
file.Write(binaryData, 0, (int)pngStream.Length);
file.Flush();
file.Close();
}
}
}
How to do it? I'll be grateful to anyone who will help me. Thanks in advance.
Assuming ASP.net...
You need to use HttpServerUtility.MapPath to compute location of the path on your server and potentially adjust permissions on that folder to allow IIS to write there.