public static MachineDocumentsData getFileNamePath(string fileId, string filenameStr, string colName) { string filePath = ""; MachineDocumentsData data = new MachineDocumentsData(); try { byte[] fileByte = null; string fileBase64 = ""; fileByte = MongoDBAccess.getEDocFilesInByte(fileId, colName); if (fileByte != null) { fileBase64 = Convert.ToBase64String(fileByte); } string fileName = filenameStr; if (!string.IsNullOrEmpty(fileBase64)) { string extension = ""; if (filenameStr != "") { var list = filenameStr.Split('.').ToList(); extension = list[list.Count - 1].ToLower(); } string filetype = ""; if ((extension == "mp4") || (extension == "wmv") || (extension == "avi") || (extension == "mov") || (extension == "qt") || (extension == "yuv") || (extension == "mkv") || (extension == "webm") || (extension == "flv") || (extension == "ogg") || (extension == "gif")) { filetype = "video"; } else if (extension == "png" || extension == "jpg" || extension == "tif" || extension == "tiff" || extension == "bmp" || extension == "jpeg" || extension == "gif" || extension == "eps" || extension == "tif" || extension == "tif" || extension == "tif") { filetype = "image"; } else if (extension == "pdf") { filetype = "pdf"; } else if (extension == "xlsx" || extension == "xlsm" || extension == "xlsb" || extension == "xltx" || extension == "xltm" || extension == "xls" || extension == "xlt" || extension == "xml" || extension == "xlam" || extension == "xlw" || extension == "xlr") { filetype = "excel"; } else { filetype = "other"; } // data.FileName = "MachineFiles/" + fileName + "#toolbar=0"; data.FileName = filenameStr; data.FileInBase64 = fileBase64; data.FileType = filetype; data.FileExtension = extension; } else { data.FileName = ""; data.FileInBase64 = ""; data.FileType = ""; data.FileExtension = ""; } } catch (Exception ex) { data.FileName = ""; data.FileInBase64 = ""; data.FileType = ""; data.FileExtension = ""; } HttpContext.Current.Session["eDocDetailsForDownload"] = data; return(data); }