void CarregaDados() { try { string sPath = ""; if (cbxPrograma.SelectedIndex == 0) { sPath = ConfigurationManager.AppSettings["DownloadGera"].ToString(); } else { sPath = ConfigurationManager.AppSettings["DownloadSPED"].ToString(); } DirectoryInfo dinfo = new DirectoryInfo(sPath); DirectoryInfo[] diretorios; if (cbxTpExe.SelectedIndex == 0) { diretorios = dinfo.GetDirectories().Where(c => !c.Name.ToUpper().Contains("TESTE")).OrderByDescending(c => c.LastWriteTime).ToArray(); } else { diretorios = dinfo.GetDirectories().Where(c => c.Name.ToUpper().Contains("TESTE")).OrderByDescending(c => c.LastWriteTime).ToArray(); } List <Versoes> lVersoes = new List <Versoes>(); Versoes versao; int iCountID = 1; foreach (DirectoryInfo pasta in diretorios) { versao = new Versoes(); versao.id = iCountID; versao.Versao = pasta.Name; string sFileZip = pasta.Name.Replace("_TESTE", ""); versao.Path = pasta.FullName + "\\" + sFileZip + ".zip"; if (File.Exists(versao.Path)) { versao.Data = File.GetCreationTime(versao.Path); string PathDetalhe = pasta.FullName + "\\" + "Detalhes.txt"; if (File.Exists(PathDetalhe)) { StreamReader sr = File.OpenText(PathDetalhe); versao.Detalhes = sr.ReadToEnd(); } lVersoes.Add(versao); iCountID++; } } Session["Versoes"] = lVersoes; gvVersoes.DataSource = lVersoes; gvVersoes.DataBind(); } catch (Exception ex) { HlpMessageBox.ShowPopUpMsg(ex.Message, this); } }
protected void gvVersoes_SelectedIndexChanged(object sender, EventArgs e) { int id = Convert.ToInt32(gvVersoes.SelectedDataKey[0].ToString()); if (((List <Versoes>)Session["Versoes"]).Where(c => c.id == id).Count() > 0) { HlpMessageBox.ShowPopUpMsg(((List <Versoes>)Session["Versoes"]).FirstOrDefault(c => c.id == id).Detalhes, this); } else { //Mensagem } }