๐ฉโ๐ป ๅ็ๅญๆช(base64 to image)
byte[] imageBytes = Convert.FromBase64String(syncImg.StrBase64Img);
using (var ms = new MemoryStream(imageBytes, 0, imageBytes.Length))
{
System.Drawing.Image image = System.Drawing.Image.FromStream(ms, true);
image.Save(path);
}
ไผบๆๅจๅๅพๆชๆก่ทฏๅพ่ๅปบ็ซ็ฎ้โ
/// <summary>
/// ๅๅพๅ็่ณๆๅคพ
/// ่ณๆๅคพไธๅญๅจๅฐฑๅปบ็ซ
/// </summary>
/// <returns></returns>
private string GetFolder()
{
var storagePath = System.Web.Hosting.HostingEnvironment.MapPath("~/"+ type);
if (!System.IO.Directory.Exists(storagePath))
{
System.IO.Directory.CreateDirectory(storagePath);
}
return storagePath;
}
ๅ็่ณ่จไฟฎๆน (ไปปๆๆชๆก้็จ)โ
var folder = new DirectoryInfo(storagePath);
IEnumerable<FileInfo> imgList = folder.GetFiles().Where(fi => fi.Name == syncImg.Name);
imgList.First().CreationTime = syncImg.UpdateDateTime; // ๅปบ็ซๆ้
imgList.First().LastWriteTime = syncImg.UpdateDateTime;// ็ทจ่ผฏๆ้
ๆฐธไน ๅช้คๅ็ (ไปปๆๆชๆก้็จ)โ
imgList.Where(fi => fi.Name == del.Key).First().Delete();