コード例 #1
0
ファイル: Gboard.cs プロジェクト: ylx2016/imewlconverter
        public IList <string> Export(WordLibraryList wlList)
        {
            //对全拼方案进行编码转换
            wlList = Filter(wlList);
            string tempPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "dictionary.txt");

            if (File.Exists(tempPath))
            {
                File.Delete(tempPath);
            }
            var sb = new StringBuilder();

            sb.Append("# Gboard Dictionary version:1\n");
            for (int i = 0; i < wlList.Count; i++)
            {
                sb.Append(ExportLine(wlList[i]));
                sb.Append("\n");
            }
            FileOperationHelper.WriteFile(tempPath, new UTF8Encoding(false), sb.ToString());
            string zipPath = Path.Combine(FileOperationHelper.GetCurrentFolderPath(), "Gboard词库.zip");

            if (File.Exists(zipPath))
            {
                File.Delete(zipPath);
            }
            FileOperationHelper.ZipFile(tempPath, zipPath);
            return(new List <string>()
            {
                "词库文件在:" + zipPath
            });
            //return new List<string>() { sb.ToString() };
        }