Files
OnDoc/Client - Kopie (2)/Helper/FileHelper.cs
Stefan Hutter 4093f8764d update 20241224
2024-12-24 11:13:02 +01:00

43 lines
1017 B
C#

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
namespace OnDoc.Helper
{
public class FileHelper
{
public bool SaveBase64ToFile(string Base64String, string filename)
{
try
{
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(Base64String));
return true;
}
catch
{
return false;
}
}
public Stream GenerateStreamFromString(string s)
{
var stream = new MemoryStream();
var writer = new StreamWriter(stream);
writer.Write(s);
writer.Flush();
stream.Position = 0;
return stream;
}
public String Base64FromFile(string filename)
{
Byte[] bytes = File.ReadAllBytes(filename);
return Convert.ToBase64String(bytes);
}
}
}