private void bInstall_Click(object sender, EventArgs e) { if (Directory.Exists(ClientInfo.path)) { IMG_Archive gta3img = new IMG_Archive(ClientInfo.path + @"/models/gta3.img"); string backupDirPath = string.Empty; lStatus.Text = "Установка..."; ClientInfo.modpackstatus = 1; pbFileProgess.Value = 0; try { string[] pathes = Directory.GetFiles(Directory.GetCurrentDirectory() + @"/ModPack"); for (int i = 0; i < pathes.Length; i++) { pathes[i] = Path.GetFileName(pathes[i]); } gta3img.Replace(Directory.GetFiles(Directory.GetCurrentDirectory() + @"/ModPack"), pathes, true, backupDirPath, pbFileProgess); ClientInfo.modpackstatus = 2; lStatus.Text = "Установлено"; pbFileProgess.Value = 100; } catch (Exception ex) { MessageBox.Show("Error: " + ex.Message, "FATAL ERROR", MessageBoxButtons.OK, MessageBoxIcon.Error); } } else { MessageBox.Show("Выберете путь с GTA SA"); } }
///<summary> ///Open( путь к архиву ). /// <returns> /// Вернет true при успешном открытии архива. /// Вернет false в том случае, если архив был открыт, путь некорректный или произошла ошибка при инициализации класса. /// </returns> ///</summary> public bool Open(string path, bool check = true) { /* open(path, false) обновит данные архива */ if (check) if (archive != null) return false; if (!File.Exists(path)) return false; try { archivePath = path; archive = new IMG_Archive(path); // open } catch(Exception ex) { Console.WriteLine( ex.Message ); return false; } return true; }
void OpenArchive(string filePath) { Archive = new IMG_Archive(filePath); DataTable dt = new DataTable(); dt.Columns.Add("Name", typeof(string)); dt.Columns.Add("Offset", typeof(uint)); dt.Columns.Add("Size", typeof(int)); for (int a = 0; a < Archive.Items.Count; a++) { DataRow dr = dt.NewRow(); dr["Name"] = Archive.Items[a].Name; dr["Offset"] = Archive.Items[a].OffsetInBytes; dr["Size"] = Archive.Items[a].SizeInBytes; dt.Rows.Add(dr); } dt.Columns["Offset"].ColumnName = "Offset (bytes)"; dt.Columns["Size"].ColumnName = "Size (bytes)"; dataGridView1.DataSource = dt; CurrentFilePath = filePath; }