Esempio n. 1
0
        public static OfficeToXpsConversionResult ConvertToXps(string sourceFilePath, ref string resultFilePath)
        {
            var result = new OfficeToXpsConversionResult(ConversionResult.UnexpectedError);

            // Check to see if it's a valid file
            if (!IsValidFilePath(sourceFilePath))
            {
                result.Result     = ConversionResult.InvalidFilePath;
                result.ResultText = sourceFilePath;
                return(result);
            }



            var ext = Path.GetExtension(sourceFilePath).ToLower();

            // Check to see if it's in our list of convertable extensions
            if (!IsConvertableFilePath(sourceFilePath))
            {
                result.Result     = ConversionResult.InvalidFileExtension;
                result.ResultText = ext;
                return(result);
            }

            // Convert if Word
            if (wordExtensions.Contains(ext))
            {
                return(ConvertFromWord(sourceFilePath, ref resultFilePath));
            }

            // Convert if Excel
            if (excelExtensions.Contains(ext))
            {
                return(ConvertFromExcel(sourceFilePath, ref resultFilePath));
            }

            // Convert if Outlook
            if (outlookExtensions.Contains(ext))
            {
                return(ConvertFromOutlook(sourceFilePath, ref resultFilePath));
            }

            // Convert if PowerPoint
            if (powerpointExtensions.Contains(ext))
            {
                return(ConvertFromPowerPoint(sourceFilePath, ref resultFilePath));
            }

            return(result);
        }
Esempio n. 2
0
        public static OfficeToXpsConversionResult ConvertToXps(string sourceFilePath, ref string resultFilePath)
        {
            var result = new OfficeToXpsConversionResult(ConversionResult.UnexpectedError);

            // Check to see if it's a valid file
            if (!IsValidFilePath(sourceFilePath))
            {
                result.Result = ConversionResult.InvalidFilePath;
                result.ResultText = sourceFilePath;
                return result;
            }

            var ext = Path.GetExtension(sourceFilePath).ToLower();

            // Check to see if it's in our list of convertable extensions
            if (!IsConvertableFilePath(sourceFilePath))
            {
                result.Result = ConversionResult.InvalidFileExtension;
                result.ResultText = ext;
                return result;
            }

            // Convert if Word
            if (wordExtensions.Contains(ext))
            {
                return ConvertFromWord(sourceFilePath, ref resultFilePath);
            }

            // Convert if Excel
            if (excelExtensions.Contains(ext))
            {
                return ConvertFromExcel(sourceFilePath, ref resultFilePath);
            }

            // Convert if Outlook
            if (outlookExtensions.Contains(ext))
            {
                return ConvertFromOutlook(sourceFilePath, ref resultFilePath);
            }

            // Convert if PowerPoint
            if (powerpointExtensions.Contains(ext))
            {
                return ConvertFromPowerPoint(sourceFilePath, ref resultFilePath);
            }

            return result;
        }