public async static Task <bool> SaveDataUriToFile(string dataUri, string filePath) { try { int index = dataUri.IndexOf("base64,", StringComparison.Ordinal) + 7; byte[] imageBytes = Convert.FromBase64String(dataUri.Substring(index)); await FileHelpers.WriteAllBytesRetry(filePath, imageBytes); ProjectHelpers.AddFileToActiveProject(filePath); return(true); } catch (Exception ex) { Logger.ShowMessage(ex.Message, "Web Essentials " + ex.GetType().Name, MessageBoxButtons.OK, MessageBoxIcon.Error); return(false); } }