/* * 上传图片,复制的软件目录下 */ private String uploadWord(Button btn, string sourceFilePath) { string ext = FileUtil.getExt(sourceFilePath); if (ext != "doc" && ext != "docx" && ext != "xps" && ext != "pdf") { return(""); } //1.复制到软件目录 String origFilename = FileUtil.getFilename(sourceFilePath); string yyyyMMdd = DateTime.Now.ToString("yyyyMMdd"); string guid = System.Guid.NewGuid().ToString("N"); String destFilePath = "/myfile/upload/Word/" + yyyyMMdd + "/" + guid + "/" + origFilename; String fullDestFilePath = AppDomain.CurrentDomain.BaseDirectory + destFilePath; FileUtil.createDirectoryIfNotExits(fullDestFilePath); File.Copy(sourceFilePath, fullDestFilePath); //转换为xps if (ext == "doc" || ext == "docx" || ext == "pdf") { string newDestFilePath = FileUtil.replaceExt(destFilePath, "xps"); // XpsDocument xpsDocument = WordUtil.ConvertWordToXPS(fullDestFilePath, AppDomain.CurrentDomain.BaseDirectory + newDestFilePath); // xpsDocument.Close(); Boolean b = WordUtil.ConvertToXPS(fullDestFilePath, AppDomain.CurrentDomain.BaseDirectory + newDestFilePath); destFilePath = newDestFilePath; } return(destFilePath); }