├── .gitignore
├── .vs
└── DecodeCode
│ └── v14
│ └── .suo
├── DecodeCode.sln
└── DecodeCode
├── App.config
├── DecodeCode.csproj
├── Program.cs
└── Properties
└── AssemblyInfo.cs
/.gitignore:
--------------------------------------------------------------------------------
1 | obj
2 | bin
3 |
--------------------------------------------------------------------------------
/.vs/DecodeCode/v14/.suo:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/Dandy521/DecodeCode/ae1e355c2fead8c238b9c1f4786e0feba653e5d6/.vs/DecodeCode/v14/.suo
--------------------------------------------------------------------------------
/DecodeCode.sln:
--------------------------------------------------------------------------------
1 |
2 | Microsoft Visual Studio Solution File, Format Version 12.00
3 | # Visual Studio 14
4 | VisualStudioVersion = 14.0.25420.1
5 | MinimumVisualStudioVersion = 10.0.40219.1
6 | Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DecodeCode", "DecodeCode\DecodeCode.csproj", "{35313544-150F-41B1-A41E-D6AD09BDEB9B}"
7 | EndProject
8 | Global
9 | GlobalSection(SolutionConfigurationPlatforms) = preSolution
10 | Debug|Any CPU = Debug|Any CPU
11 | Release|Any CPU = Release|Any CPU
12 | EndGlobalSection
13 | GlobalSection(ProjectConfigurationPlatforms) = postSolution
14 | {35313544-150F-41B1-A41E-D6AD09BDEB9B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15 | {35313544-150F-41B1-A41E-D6AD09BDEB9B}.Debug|Any CPU.Build.0 = Debug|Any CPU
16 | {35313544-150F-41B1-A41E-D6AD09BDEB9B}.Release|Any CPU.ActiveCfg = Release|Any CPU
17 | {35313544-150F-41B1-A41E-D6AD09BDEB9B}.Release|Any CPU.Build.0 = Release|Any CPU
18 | EndGlobalSection
19 | GlobalSection(SolutionProperties) = preSolution
20 | HideSolutionNode = FALSE
21 | EndGlobalSection
22 | EndGlobal
23 |
--------------------------------------------------------------------------------
/DecodeCode/App.config:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 |
6 |
--------------------------------------------------------------------------------
/DecodeCode/DecodeCode.csproj:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | Debug
6 | AnyCPU
7 | {35313544-150F-41B1-A41E-D6AD09BDEB9B}
8 | Exe
9 | Properties
10 | DecodeCode
11 | DecodeCode
12 | v4.5.2
13 | 512
14 | true
15 |
16 |
17 | AnyCPU
18 | true
19 | full
20 | false
21 | bin\Debug\
22 | DEBUG;TRACE
23 | prompt
24 | 4
25 |
26 |
27 | AnyCPU
28 | pdbonly
29 | true
30 | bin\Release\
31 | TRACE
32 | prompt
33 | 4
34 |
35 |
36 |
37 |
38 |
39 |
40 |
41 |
42 |
43 |
44 |
45 |
46 |
47 |
48 |
49 |
50 |
51 |
52 |
53 |
60 |
--------------------------------------------------------------------------------
/DecodeCode/Program.cs:
--------------------------------------------------------------------------------
1 | using System;
2 | using System.Collections.Generic;
3 | using System.IO;
4 | using System.Linq;
5 | using System.Text;
6 | using System.Threading.Tasks;
7 |
8 | namespace DecodeCode
9 | {
10 | class Program
11 | {
12 | static void Main(string[] args)
13 | {
14 | string dir = @"G:\miui";
15 | if (args.Length > 0)
16 | dir = args[0].ToString();
17 | else
18 | {
19 | Console.WriteLine("请输入路径");
20 | dir = Console.ReadLine();
21 | }
22 | if (!Directory.Exists(dir)&& !File.Exists(dir))
23 | {
24 | Console.WriteLine("路径不存在!");
25 | }
26 | else
27 | {
28 | var dirInfo = new DirectoryInfo(dir);
29 | if (dirInfo.Root.Name==dirInfo.Name)
30 | {
31 | Console.WriteLine("不支持根目录!");
32 | }else if(Directory.Exists(dir))
33 | {
34 | DecodeDir(Path.GetFullPath(dir));
35 | }else if (File.Exists(dir))
36 | {
37 | DecodeFile(Path.GetFullPath(dir));
38 | }
39 | }
40 | Console.ReadKey();
41 | }
42 | static void DecodeDir(string dirStr)
43 | {
44 | string newDir = dirStr + "_new";
45 | string[] files = Directory.GetFiles(dirStr, "*.*", SearchOption.AllDirectories);
46 | System.Diagnostics.Process p = new System.Diagnostics.Process();
47 | p.StartInfo.FileName = "cmd.exe";
48 | p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
49 | p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
50 | p.StartInfo.RedirectStandardOutput = false;//不需要获取输出信息
51 | p.StartInfo.RedirectStandardError = true;//不需要重定向标准错误输出,但false时下面的指令未执行
52 | p.StartInfo.CreateNoWindow = true;//不显示程序窗口
53 | p.Start();//启动程序
54 | StreamWriter mySR = p.StandardInput;
55 | string newFilePath = null;
56 | string newFileDir = null;
57 | Console.WriteLine("开始复制处理。。。");
58 | int j = 0;
59 | for (int nowIdx = 0; nowIdx < files.Length; nowIdx++)
60 | {
61 | if(((1+nowIdx)*10.0 / files.Length) >j)
62 | {
63 | j++;
64 | Console.WriteLine(string.Format("{0:P1}", (nowIdx + 1.0f) / files.Length));
65 | }
66 | newFilePath = newDir+ files[nowIdx].Replace(dirStr, "")+"_dandy";
67 | newFileDir = Path.GetDirectoryName(newFilePath);
68 | if (!Directory.Exists(newFileDir))
69 | Directory.CreateDirectory(newFileDir);
70 | mySR.WriteLine($"copy \"{files[nowIdx]}\" \"{newFilePath}\" /y");
71 | //str表示一行命令
72 | //mySR.WriteLine(str[nowIdx]);
73 | //这里的Flush()操作和我理解的不一样,尽管flush了但是命令行并没有立即执行
74 | //而且当需要执行的命令行数量十分多的时候,在使用了WriteLine后会在随机行数之后值执行,可能与缓冲区大小有关
75 | mySR.Flush();
76 | }
77 | //这个地方我对于原文所提供的exit和&exit的区别没有完全弄清,以后可能进行补充
78 | p.StandardInput.WriteLine("&exit");
79 | //关闭StreamWriter后,之前输入的命令行会立即执行
80 | mySR.Close();
81 | p.WaitForExit();
82 | p.Close();
83 | Console.WriteLine("开始重命名处理。。。");
84 | string[] newfiles = Directory.GetFiles(newDir,"*.*",SearchOption.AllDirectories);
85 | foreach(var nf in newfiles)
86 | {
87 | File.Move(nf,nf.Substring(0,nf.LastIndexOf("_dandy")));
88 | }
89 | Console.WriteLine("处理完成!");
90 | }
91 |
92 |
93 | static void DecodeFile(string pathStr)
94 | {
95 | string newFile = Path.GetDirectoryName(pathStr)+"\\"+"new_"+ Path.GetFileName(pathStr) + "_dandy";
96 | System.Diagnostics.Process p = new System.Diagnostics.Process();
97 | p.StartInfo.FileName = "cmd.exe";
98 | p.StartInfo.UseShellExecute = false; //是否使用操作系统shell启动
99 | p.StartInfo.RedirectStandardInput = true;//接受来自调用程序的输入信息
100 | p.StartInfo.RedirectStandardOutput = false;//不需要获取输出信息
101 | p.StartInfo.RedirectStandardError = true;//不需要重定向标准错误输出,但false时下面的指令未执行
102 | p.StartInfo.CreateNoWindow = true;//不显示程序窗口
103 | p.Start();//启动程序
104 | StreamWriter mySR = p.StandardInput;
105 | Console.WriteLine("开始复制处理。。。");
106 | mySR.WriteLine($"copy \"{pathStr}\" \"{newFile}\" /y");
107 | //str表示一行命令
108 | //mySR.WriteLine(str[nowIdx]);
109 | //这里的Flush()操作和我理解的不一样,尽管flush了但是命令行并没有立即执行
110 | //而且当需要执行的命令行数量十分多的时候,在使用了WriteLine后会在随机行数之后值执行,可能与缓冲区大小有关
111 | mySR.Flush();
112 | //这个地方我对于原文所提供的exit和&exit的区别没有完全弄清,以后可能进行补充
113 | p.StandardInput.WriteLine("&exit");
114 | //关闭StreamWriter后,之前输入的命令行会立即执行
115 | mySR.Close();
116 | p.WaitForExit();
117 | p.Close();
118 | Console.WriteLine("开始重命名处理。。。");
119 | File.Move(newFile, newFile.Substring(0, newFile.LastIndexOf("_dandy")));
120 | Console.WriteLine("处理完成!");
121 | }
122 | }
123 | }
124 |
--------------------------------------------------------------------------------
/DecodeCode/Properties/AssemblyInfo.cs:
--------------------------------------------------------------------------------
1 | using System.Reflection;
2 | using System.Runtime.CompilerServices;
3 | using System.Runtime.InteropServices;
4 |
5 | // 有关程序集的一般信息由以下
6 | // 控制。更改这些特性值可修改
7 | // 与程序集关联的信息。
8 | [assembly: AssemblyTitle("DecodeCode")]
9 | [assembly: AssemblyDescription("")]
10 | [assembly: AssemblyConfiguration("")]
11 | [assembly: AssemblyCompany("")]
12 | [assembly: AssemblyProduct("DecodeCode")]
13 | [assembly: AssemblyCopyright("Copyright © 2019")]
14 | [assembly: AssemblyTrademark("")]
15 | [assembly: AssemblyCulture("")]
16 |
17 | //将 ComVisible 设置为 false 将使此程序集中的类型
18 | //对 COM 组件不可见。 如果需要从 COM 访问此程序集中的类型,
19 | //请将此类型的 ComVisible 特性设置为 true。
20 | [assembly: ComVisible(false)]
21 |
22 | // 如果此项目向 COM 公开,则下列 GUID 用于类型库的 ID
23 | [assembly: Guid("35313544-150f-41b1-a41e-d6ad09bdeb9b")]
24 |
25 | // 程序集的版本信息由下列四个值组成:
26 | //
27 | // 主版本
28 | // 次版本
29 | // 生成号
30 | // 修订号
31 | //
32 | //可以指定所有这些值,也可以使用“生成号”和“修订号”的默认值,
33 | // 方法是按如下所示使用“*”: :
34 | // [assembly: AssemblyVersion("1.0.*")]
35 | [assembly: AssemblyVersion("1.0.0.0")]
36 | [assembly: AssemblyFileVersion("1.0.0.0")]
37 |
--------------------------------------------------------------------------------