//检查上传的物理路径是否存在,不存在则创建
if (!Directory.Exists(filePath))
{
Directory.CreateDirectory(filePath);
}
/// 生成图片
/// </summary>
/// <param name="base64String">文件</param>
/// <param name="fileName">文件路径+文件名</param>
/// <returns></returns>
public static bool StringToFile(string base64String, string fileName)
{
System.IO.FileStream fs = new System.IO.FileStream(fileName, System.IO.FileMode.Create);
System.IO.BinaryWriter bw = new System.IO.BinaryWriter(fs);
if (!string.IsNullOrEmpty(base64String) && File.Exists(fileName))
{
bw.Write(Convert.FromBase64String(base64String));
}
bw.Close();
fs.Close();
return true;
}