Good afternoon,
Since a couple of days ago I am trying to generate a report of the files that contains a Winrar, the program "Winrar" brings it in a native way, but I need it for a file manager, since my users request that it be give them the contents of an X directory.
I am currently generating everything related to normal files and folders, but I must also add the contents of the .rar files that are in the selected directory to the same file (.xls).
The code you use for excel is this:
using (SaveFileDialog sfd = new SaveFileDialog() { Filter = "Excel Workbook|*.xls", ValidateNames = true })
{
if (sfd.ShowDialog() == DialogResult.OK)
{
Microsoft.Office.Interop.Excel.Application app = new Microsoft.Office.Interop.Excel.Application();
Workbook wb = app.Workbooks.Add(XlSheetType.xlWorksheet);
Worksheet ws = (Worksheet)app.ActiveSheet;
app.Visible = false;
ws.Cells[1, 1] = "Caso";
ws.Cells[1, 2] = "Nombre";
ws.Cells[1, 3] = "Tipo";
ws.Cells[1, 4] = "Fecha Creación";
ws.Cells[1, 5] = "Ubicación";
ws.Cells[1, 6] = "Descripción";
ws.Cells[1, 7] = "Tamaño";
ws.Cells[1, 8] = "Usuario Crea";
ws.Cells[1, 9] = "Descarga";
int i = 2;
int j = 0;
foreach (ListViewItem item in lv_4_detalle.Items)
{
ws.Cells[i, 1] = item.SubItems[0].Text;
ws.Cells[i, 2] = item.SubItems[1].Text;
ws.Cells[i, 3] = item.SubItems[2].Text;
ws.Cells[i, 4] = item.SubItems[3].Text;
ws.Cells[i, 5] = item.SubItems[4].Text;
ws.Cells[i, 6] = item.SubItems[5].Text;
ws.Cells[i, 7] = item.SubItems[6].Text;
ws.Cells[i, 8] = item.SubItems[7].Text;
ws.Cells[i, 9] = item.SubItems[8].Text;
i++;
if ((".rar" == (ws.Cells[i, 3] = item.SubItems[2].Text)) || (".zip" == (ws.Cells[i, 3] = item.SubItems[2].Text)))
{
string ruta = item.SubItems[4].Text + "\" + item.SubItems[1].Text;
MessageBox.Show(ruta);
System.Diagnostics.Process proc = new System.Diagnostics.Process();
proc.EnableRaisingEvents = false;
proc.StartInfo.FileName = "cmd";
proc.StartInfo.RedirectStandardInput = true;
proc.StartInfo.RedirectStandardOutput = true;
//proc.StartInfo.CreateNoWindow = true;
proc.StartInfo.UseShellExecute = false;
proc.Start();
proc.StandardInput.WriteLine(@"rar l " + ruta); //+">> E:\test"+ i +".csv");
proc.StandardInput.Flush();
//proc.StandardInput.Close();
proc.Close();
//proc.WaitForExit();
//j++;
//MessageBox.Show("prueba " +j);
}
}
wb.SaveAs(sfd.FileName, XlFileFormat.xlWorkbookNormal,Type.Missing, Type.Missing, true, false, XlSaveAsAccessMode.xlNoChange, XlSaveConflictResolution.xlLocalSessionChanges, Type.Missing, Type.Missing);
app.Quit();
MessageBox.Show("Se ha exportado la informacion", "Message", MessageBoxButtons.OK, MessageBoxIcon.Information);
}
}
}
This code works to create the Excel, and the rar works locally but when using it through the Server it gives an Access error.
The report generated by winrar is like this:
You think there is a bookstore that will help me get the information I need.
And the one that I need to generate is very similar.
Thank you very much for your comments.