private void ToDecode() { string targetPath = _save.OutputPath; string tFile = null; for (int i = 0; i < lstFiles.Items.Count; i++) { string sourceFile = lstFiles.Items[i].ToString(); msg.Log("正在转换:" + sourceFile); try { using (FileStream stmSource = File.Open(sourceFile, FileMode.Open)) { FileInfo finfo = new FileInfo(sourceFile); string sourceEx = finfo.Extension.Trim('.'); IMusicDecode decode = DecoderManager.CreateDecode(sourceEx); if (decode == null) { msg.LogError(sourceEx + "文件不存在解码"); return; } decode.Load(stmSource, sourceEx); tFile = GetTargetPath(targetPath, sourceFile, decode); decode.Dump(tFile); } } catch (Exception ex) { msg.LogError(ex.ToString()); } msg.Log(sourceFile + " 转换完毕"); SetProcess(i); } SetProcess(0); MessageBox.Show("转换完毕", "提示", MessageBoxButtons.OK, MessageBoxIcon.Information); msg.Log("转换完毕"); EnableDecode(false); this.Invoke((EventHandler) delegate { lstFiles.Items.Clear(); }); }
private void AddToList(IEnumerable <string> files) { string exName = null; foreach (string fileName in files) { FileInfo finfo = new FileInfo(fileName); exName = finfo.Extension; if (string.IsNullOrWhiteSpace(exName)) { continue; } exName = exName.Trim('.'); if (DecoderManager.HasDecode(exName)) { lstFiles.Items.Add(fileName); } } }