public bool bCriaBackup() { try { m_cls_dba_ConectionDB.Log = true; m_cls_dba_ConectionDB.FonteDosDados = mdlDataBaseAccess.FonteDados.DataBase; System.Collections.ArrayList arlListaArquivo = new System.Collections.ArrayList(); System.Data.DataSet dtsetTemp = new System.Data.DataSet("Backup"); invocarMetodosDataAccessGet(ref dtsetTemp); System.Data.DataTable dtTbTemp = new System.Data.DataTable(TBVERSAOBACKUPTEXTO); dtTbTemp.Columns.Add(DATABACKUP, System.Type.GetType("System.DateTime")); dtTbTemp.Columns.Add(VERSAOBACKUPTEXTO, System.Type.GetType("System.String")); dtTbTemp.Columns.Add(VERSAOSISCOBRASTEXTO, System.Type.GetType("System.String")); System.Data.DataRow dtRow = dtTbTemp.NewRow(); dtRow[DATABACKUP] = m_dtDataBackup; dtRow[VERSAOBACKUPTEXTO] = m_rdRandomico.Next().ToString(); dtRow[VERSAOSISCOBRASTEXTO] = m_rdRandomico.Next().ToString(); dtsetTemp.Tables.Add(dtTbTemp); if (!System.IO.Directory.Exists(m_strDiretorioTemporario)) { System.IO.Directory.CreateDirectory(m_strDiretorioTemporario); } dtsetTemp.WriteXml(m_strDiretorioTemporario + "\\" + ARQUIVOXML, System.Data.XmlWriteMode.WriteSchema); arlListaArquivo.Add(m_strDiretorioTemporario + "\\" + ARQUIVOXML); mdlCompactacao.clsCompactacao obj = new mdlCompactacao.clsCompactacao(ref m_cls_ter_tratadorErro); if (!System.IO.Directory.Exists(m_strEnderecoBackup)) { System.IO.Directory.CreateDirectory(m_strEnderecoBackup); } if (System.IO.File.Exists(m_strEnderecoBackup + "\\" + m_strArquivoBackup)) { System.IO.File.Delete(m_strEnderecoBackup + "\\" + m_strArquivoBackup); } obj.compacta(ref arlListaArquivo, m_strEnderecoBackup + "\\" + m_strArquivoBackup, mdlCompactacao.NIVELCOMPACTACAO.MAXIMO); try { System.IO.File.Delete(m_strDiretorioTemporario + "\\" + ARQUIVOXML); System.IO.Directory.Delete(m_strDiretorioTemporario, true); } catch { } } catch { return(false); } return(true); }
private void button1_Click(object sender, System.EventArgs e) { System.Collections.ArrayList listaArquivos = new System.Collections.ArrayList(); System.Windows.Forms.OpenFileDialog fileDialog = new System.Windows.Forms.OpenFileDialog(); fileDialog.Multiselect = true; if (fileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK) { foreach (string files in fileDialog.FileNames) { listaArquivos.Add(files); } if (textBox1.Text.Trim() != "") { mdlCompactacao.clsCompactacao cls_Zip = new mdlCompactacao.clsCompactacao(ref m_clsErro); cls_Zip.compacta(ref listaArquivos, textBox1.Text.Trim(), mdlCompactacao.NIVELCOMPACTACAO.MAXIMO); } } }