日期:2014-05-17 浏览次数:20466 次
/// <summary> /// PDFToSWF /// </summary> /// <param name="uploadFilepath"></param> /// <param name="file"></param> public static void AsConvertFile(string uploadFilepath, string file) { if (uploadFilepath == null || string.IsNullOrEmpty(AsFileHelper.AsCheckFileType(uploadFilepath))) { return; } else { if (uploadFilepath.EndsWith(".pdf"))//如果上传的文件是PDF格式 { string swfpath = uploadFilepath.Replace(".pdf", ".swf"); if (AsConvertHelper.AsConvertToSwf(uploadFilepath, swfpath)) { GetResponseUrl(Path.GetFileName(swfpath)); } } else { string uploadFile = AsFileHelper.AsCheckFileType(uploadFilepath);//如果上传的文件不是DPF格式的文件 file = uploadFilepath.Replace(uploadFile, ".pdf"); if (!File.Exists(file)) { string PDFFolder = file.Replace("UploadFile", "PdfFile");//PDF文件保存的文件夹路径 bool isconvert = AsConvertHelper.AsConvertToPDF(uploadFilepath, PDFFolder); if (isconvert) { string swfpath = PDFFolder.Replace(".pdf", ".swf"); if (AsConvertHelper.AsConvertToSwf(PDFFolder, swfpath)) { GetResponseUrl(Path.GetFileName(swfpath)); } } } } } }
if (uploadFilepath == null || string.IsNullOrEmpty( AsFileHelper.AsCheckFileType(uploadFilepath))){ return; }替换如下: MyHelper.Assert(uploadFilepath!=null,new ArgumentNullException("errMsg1")); string _s=AsFileHelper.AsCheckFileType(uploadFilepath); MyHelper.Assert(!string.IsNullOrEmpty(_s),new ArgumentException("errMsg2"));
------解决方案--------------------
#region private static String ConvertToPDF(String uploadFilePath) //转为PDF文件 //----------------------------------------------------- /// <summary> /// 转为PDF文件 /// </summary> /// <param name="uploadFilePath"></param> /// <returns></returns> private static String ConvertToPDF(String uploadFilePath) { String strPDFPath = String.Empty; if (AsConvertHelper.AsConvertPDF(uploadFilePath, strPDFPath)) { return strPDFPath; } return String.Empty; } //----------------------------------------------------- #endregion #region private static String ConvertToSwf(String uploadFilePath) //转为SWF文件 //----------------------------------------------------- /// <summary> /// 转为SWF文件 /// </summary> /// <param name="uploadFilePath"></param> /// <returns></returns> private static String ConvertToSwf(String uploadFilePath) { String strSwfPath = uploadFilePath.Repl