protected void GridView1_RowCommand(object sender, GridViewCommandEventArgs e) { int rowIndex = Convert.ToInt32(e.CommandArgument); FilesObject.DownloadFile( GridView1.DataKeys[rowIndex].Values[1].ToString()); }
protected FilesObject[] ListSysFiles(int Id, String FilesKind, Boolean IsImageList) { String tpl_FolderPath = String.Empty; String Path = String.Empty; String AccessFilesKind = FilesKind == "" ? "DocFiles" : FilesKind; tpl_FolderPath = String.Format(SystemUpFilePathTpl, GetArea, GetController, Id, AccessFilesKind, "OriginFile"); Path = Server.MapPath(tpl_FolderPath); IsImageList = false; if (Directory.Exists(Path)) { String[] CheckFiles = Directory.GetFiles(Path); if (CheckFiles.Count() > 0) { String FileListTypeCheck = CheckFiles.FirstOrDefault(); FileInfo GetFirstFileToCheck = new FileInfo(FileListTypeCheck); if (GetFirstFileToCheck.Extension.ToLower().Contains("jpg") || GetFirstFileToCheck.Extension.ToLower().Contains("jpeg") || GetFirstFileToCheck.Extension.ToLower().Contains("png") || GetFirstFileToCheck.Extension.ToLower().Contains("gif") || GetFirstFileToCheck.Extension.ToLower().Contains("bmp")) { tpl_FolderPath = String.Format(SystemUpFilePathTpl, GetArea, GetController, Id, AccessFilesKind, "RepresentICON"); Path = Server.MapPath(tpl_FolderPath); IsImageList = true; } } } //LogWrite.Write("File List"+ Path); List <FilesObject> ls_Files = new List <FilesObject>(); if (Directory.Exists(Path)) { foreach (String fileString in Directory.GetFiles(Path)) { FileInfo fi = new FileInfo(fileString); FilesObject fo = new FilesObject() { FileName = fi.Name, FilesKind = FilesKind, RepresentFilePath = Url.Content(tpl_FolderPath + "/" + fi.Name) }; if (fi.Extension.ToLower().Contains("jpg") || fi.Extension.ToLower().Contains("jpeg") || fi.Extension.ToLower().Contains("png") || fi.Extension.ToLower().Contains("gif") || fi.Extension.ToLower().Contains("bmp")) { fo.IsImage = true; } if (IsImageList) { String org_tpl_FolderPath = String.Format(SystemUpFilePathTpl, GetArea, GetController, Id, AccessFilesKind, "OriginFile"); Path = Server.MapPath(org_tpl_FolderPath); fi = new FileInfo(Path + "/" + fi.Name); fo.OriginFilePath = Url.Content(org_tpl_FolderPath + "/" + fi.Name); fo.Size = fi.Length; } else { fo.OriginFilePath = Url.Content(tpl_FolderPath + "/" + fi.Name); fo.Size = fi.Length; } ls_Files.Add(fo); } } return(ls_Files.ToArray()); }