Update 20250222
This commit is contained in:
62
OfficeToPDFConverter/clsFileHelper.cs
Normal file
62
OfficeToPDFConverter/clsFileHelper.cs
Normal file
@@ -0,0 +1,62 @@
|
||||
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.IO;
|
||||
using System.Linq;
|
||||
using System.Text;
|
||||
using System.Threading.Tasks;
|
||||
|
||||
namespace Helper
|
||||
{
|
||||
public class clsFileHelper_Converter
|
||||
{
|
||||
public string save_temp_file(string data, string dokumentid, string temppath, string extension)
|
||||
{
|
||||
string filename = "";
|
||||
filename = temppath + DateTime.Now.ToString("yyyyMMddhhmmss") + "_" + dokumentid + "." + extension;
|
||||
|
||||
//if (docfilename != "")
|
||||
//{
|
||||
// filename = temppath + DateTime.Now.ToString("yyyyMMddhhmmss") + "_" + docfilename;
|
||||
//}
|
||||
try
|
||||
{
|
||||
System.IO.File.WriteAllBytes(filename, Convert.FromBase64String(data));
|
||||
return filename;
|
||||
}
|
||||
catch
|
||||
{
|
||||
return "";
|
||||
}
|
||||
}
|
||||
|
||||
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);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user