You can not select more than 25 topics
Topics must start with a letter or number, can include dashes ('-') and can be up to 35 characters long.
24 lines
651 B
24 lines
651 B
using System;
|
|
using System.Collections.Generic;
|
|
using System.IO;
|
|
using System.Text;
|
|
|
|
namespace Shentun.Utilities
|
|
{
|
|
public class FileHelper
|
|
{
|
|
public static string ToBase64(string filename)
|
|
{
|
|
Stream stream;
|
|
string fileBase64;
|
|
using (stream = new FileStream(filename, FileMode.Open, FileAccess.Read))
|
|
{
|
|
byte[] byteData = new byte[stream.Length];
|
|
stream.Read(byteData, 0, byteData.Length);
|
|
fileBase64 = Convert.ToBase64String(byteData);
|
|
stream.Close();
|
|
}
|
|
return fileBase64;
|
|
}
|
|
}
|
|
}
|