Exemple #1
0
        private void btnShowFile_Click(object sender, EventArgs e)
        {
            try
            {
                int    documentId   = Convert.ToInt32(tblPrestamosFilter.CurrentRow.Cells[0].Value);
                string folder       = AppDomain.CurrentDomain.BaseDirectory + "/temp/";
                string fullFileName = folder + documentId.ToString() + ".pdf";

                if (!Directory.Exists(folder))
                {
                    Directory.CreateDirectory(folder);
                }

                if (File.Exists(fullFileName))
                {
                    File.Delete(fullFileName);
                }

                File.WriteAllBytes(fullFileName, asignaciones.CargarDocumentoPrestamo(documentId));
                Process.Start(fullFileName);
            }
            catch (Exception)
            {
                MessageBox.Show("Se presento algun error o no hay ningun documento disponible para este registro", "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
            }
        }