@@ -22,17 +22,7 @@ private void LoadLastConfig()
2222 {
2323 pathRichTextBox . Text = path ;
2424 var paths = path . Split ( '\n ' , StringSplitOptions . RemoveEmptyEntries ) ;
25-
26- if ( paths . Length == 1 && ! paths [ 0 ] . EndsWith ( ".xsh" , StringComparison . OrdinalIgnoreCase ) )
27- {
28- // 处理目录情况
29- selectedFiles = Xclass . GetXshFiles ( paths [ 0 ] ) ?? [ ] ;
30- }
31- else
32- {
33- // 处理文件列表情况
34- selectedFiles . AddRange ( paths ) ;
35- }
25+ selectedFiles . AddRange ( paths ) ;
3626 }
3727
3828 if ( ! string . IsNullOrEmpty ( passwd ) )
@@ -99,7 +89,7 @@ private void SelectDirButton_Click(object sender, EventArgs e)
9989 pathRichTextBox . Clear ( ) ;
10090 selectedFiles . Clear ( ) ;
10191 pathRichTextBox . AppendText ( folderBrowserDialog1 . SelectedPath ) ;
102- selectedFiles = Xclass . GetXshFiles ( folderBrowserDialog1 . SelectedPath ) ;
92+ selectedFiles . Add ( folderBrowserDialog1 . SelectedPath ) ;
10393 }
10494 }
10595 }
@@ -141,7 +131,28 @@ private void DecryptButton_Click(object sender, EventArgs e)
141131 sid = Xclass . GetSid ( ) ;
142132 }
143133 dataGridView1 . Rows . Clear ( ) ;
144- foreach ( string element in selectedFiles )
134+
135+ // 处理文件列表
136+ List < string > filesToProcess = [ ] ;
137+ foreach ( string path in selectedFiles )
138+ {
139+ if ( File . Exists ( path ) && path . EndsWith ( ".xsh" , StringComparison . OrdinalIgnoreCase ) )
140+ {
141+ filesToProcess . Add ( path ) ;
142+ }
143+ else if ( Directory . Exists ( path ) )
144+ {
145+ filesToProcess . AddRange ( Xclass . GetXshFiles ( path ) ?? [ ] ) ;
146+ }
147+ }
148+
149+ if ( filesToProcess . Count == 0 )
150+ {
151+ MessageBox . Show ( this , "未找到会话文件!" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
152+ return ;
153+ }
154+
155+ foreach ( string element in filesToProcess )
145156 {
146157 var session = Xclass . FileParser ( element , sid ) ;
147158 var error = "确认主密码是否正确!" ;
@@ -155,7 +166,6 @@ private void DecryptButton_Click(object sender, EventArgs e)
155166 // 写入配置到注册表
156167 RegistryCache . WriteToRegistry ( appKey , "path" , pathRichTextBox . Text ) ;
157168 RegistryCache . WriteToRegistry ( appKey , "passwd" , masterPasswdTextBox . Text ) ;
158-
159169 }
160170 else if ( pathRichTextBox . Text == "" )
161171 {
@@ -164,7 +174,6 @@ private void DecryptButton_Click(object sender, EventArgs e)
164174 else
165175 {
166176 MessageBox . Show ( this , "未找到会话文件!" , "提示" , MessageBoxButtons . OK , MessageBoxIcon . Information ) ;
167-
168177 }
169178 }
170179
0 commit comments