Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
AI OnAI Off
Five New Optimizely Certifications are Here! Validate your expertise and advance your career with our latest certification exams. Click here to find out more
protected string GetFileTitle(string filePath, AccessLevel accessLevel) { UnifiedFile file = UnifiedFileSystem.GetFile(filePath, accessLevel); string fileName = file.Name; string fileExtension = file.Extension; string fileDescription = String.Empty; string fileSizeFormatted; string userSpecifiedFileName = String.Empty; if (file.Summary.Title != null) { userSpecifiedFileName = file.Summary.Title; } if (file.Length == 1) { fileSizeFormatted = file.Length.ToString() + "byte"; } else if (file.Length > 1 && file.Length < 1024) { fileSizeFormatted = file.Length.ToString() + "bytes"; } else if (file.Length < (1024 * 1024)) { fileSizeFormatted = (file.Length / 1024) + "KB"; } else { fileSizeFormatted = (file.Length / (1024*1024)) + "MB"; } fileDescription = "(" + fileExtension.Replace(".", String.Empty).ToUpper() + " " + fileSizeFormatted + ")"; if (userSpecifiedFileName.Trim().Length > 0) { return userSpecifiedFileName + " " + fileDescription; } else { return fileName.Replace(fileExtension, String.Empty) + " " + fileDescription; } }