• 大小: 45KB
    文件类型: .rar
    金币: 1
    下载: 0 次
    发布日期: 2021-06-09
  • 语言: 其他
  • 标签:

资源简介

简体转繁体支持批量文件转换,支持子目录的递归转换

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;
using System.Linq;
using EncodeMy;
namespace TestEnCode
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
            this.InitEvents();
        }
        private List fileExtensions = new List();
        private EncodeRobert convert = new EncodeRobert();
        private void InitEvents()
        {
            this.btnSelectDir.Click += new EventHandler(btnSelectDir_Click);
            this.btnConvertToFt.Click += new EventHandler(btnConvertToFt_Click);
        }

        void btnConvertToFt_Click(object sender EventArgs e)
        {
            fileExtensions.Clear();
            if (!String.IsNullOrEmpty(this.txtExtensions.Text))
            {
                fileExtensions = this.txtExtensions.Text.ToLower().Split(new char[]{‘;‘}StringSplitOptions.RemoveEmptyEntries).ToList();
            }
            ConvertAll(this.txtSource.Text.Trim());
            //EncodeRobert convert = new EncodeRobert();

            //txtResult.Text = convert.SCTCConvert(ConvertType.Simplified ConvertType.Traditional txtSource.Text);

            //throw new NotImplementedException();
        }

        private void ConvertAll(string sourcePath)
        {
            foreach (string fileName in Directory.GetFiles(sourcePath))
            {
                FileInfo fileInfo = new FileInfo(fileName);
                if (fileExtensions.Count > 0)
                {
                    if (!fileExtensions.Contains(fileInfo.Extension.ToLower())) continue;
                    ConvertFile(fileInfo);
                }
                else
                {
                    ConvertFile(fileInfo);
                }
            }
            foreach (string path in Directory.GetDirectories(sourcePath))
            {
                ConvertAll(path);
            }
        }

        private void ConvertFile(FileInfo fileInfo)
        {
            string fileContent = ““;
            using (StreamReader reader = new StreamReader(fileInfo.FullName Encoding.UTF8))
            {
                fileContent = reader.ReadToEnd();
            }
            File.Delete(fileInfo.FullName);
            fileContent = convert.SCTCConvert(ConvertType.Simplified ConvertType.Traditional fileContent);
            using (StreamWriter writer = new StreamWriter(fileInfo.FullName true Encoding.UTF8))
            {
                writer.Write(fileContent);
            }
            this.txtResult.Text += fileInfo.FullName + System.Environment.NewLine;
        }

        void btnSelectDir_Click(object sender EventArgs e)
        {
            FolderBrowserDialog sourceFolder = new FolderBrowserDialog();
            if(sourceFolder.ShowDialo

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

     文件       4608  2008-09-09 14:13  TestEnCode_简繁体互转\TestEnCode\bin\Debug\Encode.dll

     文件      11264  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\bin\Debug\TestEnCode.exe

     文件      26112  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\bin\Debug\TestEnCode.pdb

     文件      14328  2015-08-05 09:45  TestEnCode_简繁体互转\TestEnCode\bin\Debug\TestEnCode.vshost.exe

     文件        490  2009-06-11 05:14  TestEnCode_简繁体互转\TestEnCode\bin\Debug\TestEnCode.vshost.exe.manifest

     文件       3167  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\Form1.cs

     文件       6375  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\Form1.Designer.cs

     文件       5814  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\Form1.resx

     文件       2555  2008-09-10 10:40  TestEnCode_简繁体互转\TestEnCode\obj\Debug\ResolveAssemblyReference.cache

     文件       1770  2015-08-05 09:45  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.csproj.FileListAbsolute.txt

     文件        847  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.csproj.GenerateResource.Cache

     文件      11264  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.exe

     文件        180  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.Form1.resources

     文件      26112  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.pdb

     文件        180  2015-07-30 18:24  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TestEnCode.Properties.Resources.resources

     文件        471  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Program.cs

     文件       1368  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Properties\AssemblyInfo.cs

     文件       2870  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Properties\Resources.Designer.cs

     文件       5612  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Properties\Resources.resx

     文件       1095  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Properties\Settings.Designer.cs

     文件        249  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\Properties\Settings.settings

     文件       3604  2015-07-30 18:24  TestEnCode_简繁体互转\TestEnCode\TestEnCode.csproj

     文件        920  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode.sln

    ..A..H.     13824  2015-07-31 14:31  TestEnCode_简繁体互转\TestEnCode.suo

     目录          0  2015-07-30 17:48  TestEnCode_简繁体互转\TestEnCode\obj\Debug\Refactor

     目录          0  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\obj\Debug\TempPE

     目录          0  2008-09-10 10:40  TestEnCode_简繁体互转\TestEnCode\bin\Debug

     目录          0  2015-07-31 09:50  TestEnCode_简繁体互转\TestEnCode\obj\Debug

     目录          0  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\bin

     目录          0  2008-09-10 10:33  TestEnCode_简繁体互转\TestEnCode\obj

............此处省略6个文件信息

评论

共有 条评论