Exemplo n.º 1
0
 private void save_dialog_OnFileSelected(object sender, SelectFileDialog.SelectFileEventArgs e)
 {
     if (RAWData != null)
     {
         File.WriteAllBytes(e.FileName, RAWData);
     }
     else
     {
         this.Error("没有有效的数据");
     }
 }
Exemplo n.º 2
0
        private void select_file_OnFileSelected(object sender, SelectFileDialog.SelectFileEventArgs e)
        {
            StringBuilder information = new StringBuilder();

            cap_file.Text = e.FileName;
            try
            {
                using (FileStream stream = File.OpenRead(e.FileName))
                {
                    CAPData = new byte[stream.Length];
                    stream.Read(CAPData, 0, CAPData.Length);
                    information.AppendLine($"文件:{e.FileName}");
                    information.AppendLine($"原始数据长度:{stream.Length}");
                    int realsize = 0;
                    foreach (int i in biosLength)
                    {
                        if (CAPData.Length > i)
                        {
                            realsize = i;
                        }
                        else
                        {
                            break;
                        }
                    }
                    information.AppendLine($"匹配BIOS大小:{realsize / 1024 / 1024} MB");
                    RAWData = new byte[realsize];
                    for (int n = 0; n < realsize; n++)
                    {
                        RAWData[n] = CAPData[n + (stream.Length - realsize)];
                    }
                    information.AppendLine($"分离成功!");
                }
            }
            catch (Exception ex)
            {
                information.AppendLine("失败!");
                information.AppendLine(ex.ToString());
            }
            mesg.Text = information.ToString();
        }