文件转base64

    public static string ToBase64(string path)
    {
        using (var filestream = new FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite))
        {
            var bt = new byte[filestream.Length];
            filestream.Read(bt, 0, bt.Length);
            var base64Str = Convert.ToBase64String(bt);
            return base64Str;
        }
    }

 

你可能感兴趣的:(C#Helper)