0

我有以下 csv 文件:https ://dl.dropboxusercontent.com/u/8518063/ShareX/2016/03/simple.csv

我使用 Windows 资源管理器“发送到压缩的 zip 文件夹”并获取此文件:https ://dl.dropboxusercontent.com/u/8518063/ShareX/2016/03/simple.zip

我使用http://www.motobit.com/util/base64-decoder-encoder.asp并上传 zip 文件夹并获取此 base64 编码字符串:UEsDBBQAAAAIAMB5fEhJO+GGVQAAAIoAAAAKAAAAc2ltcGxlLmNzdk3KOwqAMBRE0V5wJzHk/ZPl CIoIQZu4f/Ms1FsMU5x6HtvermUNdW7PGYcJAGIBoISoVrxAFMkQWRVy6pn9nHFhcCavMyBxp/o5 xiw5uePXlb7uRG9QSwECFAAUAAAACADAeXxISTvhhlUAAACKAAAACgAAAAAAAAABACAAAAAAAAAA c2ltcGxlLmNzdlBLBQYAAAAAAQABADgAAAB9AAAAAAA=

我无法使用 c# 重现 base64string。我的尝试:

using System;
using System.Collections.Generic;
using System.IO;
using System.Text;
using System.IO.Compression;
var csv = @"longitude,latitude
-111.91130226799999,33.372246618000077
-111.91137494199995,33.372247135000066
-111.91142858099994,33.372249372000056";
Console.WriteLine(Convert.ToBase64String(Zip(csv)));

        public static byte[] Zip(string str)
        {
            var bytes = Encoding.UTF8.GetBytes(str);
            using (var msi = new MemoryStream(bytes))
            {
                using (var mso = new MemoryStream())
                {
                    using (var gs = new GZipStream(mso, CompressionMode.Compress))
                    {
                        msi.CopyTo(gs);
                    }
                    return mso.ToArray();
                }
            }
        }

可在此处在线运行:http: //csharppad.com/gist/e5d92798cb4a9c7887d6

返回H4sIAAAAAAAEAEXKOwqAMBBF0d61xJD5Z5YjKCIEbeL+dSziLR6vOO0696Pf65ba0r8zzQCQHYAKoppHiSiTIbIq1PJm9jNjZwglgxmQBFMdjLFKLcF4MH83mOgD8gxr24cAAAA=

4

0 回答 0