• 大小: 14.75M
    文件类型: .rar
    金币: 2
    下载: 1 次
    发布日期: 2023-06-16
  • 语言: 其他
  • 标签: 其他  

资源简介

WindowsFormsApp1.rar

资源截图

代码片段和文件信息

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace WindowsFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender EventArgs e)
        {
            string sourceFile = ““;
            using (var form = new OpenFileDialog())
            {
                form.Filter = “Word Files (*.doc;*.docx)|*.doc;*.docx“;
                form.RestoreDirectory = true;
                form.title = “Open Word File“;

                if (form.ShowDialog(this) != DialogResult.OK)
                {
                    return;
                }
                sourceFile = form.FileName;
            }

            // 转换PDF文件后保存位置
            folderBrowserDialog1.Description = “请选择转换后保存文件夹!“;
            if (folderBrowserDialog1.ShowDialog() == DialogResult.OK)
            {
                string folderPath = folderBrowserDialog1.SelectedPath;
                string last = folderPath.Substring(folderPath.Length - 1 1);
                if (!last.Equals(“\\“))
                {
                    folderPath += “\\“;
                }
                // 转换后保存的位置
                string destFolder = folderPath;
                string sourcefilename = System.IO.Path.GetFileName(sourceFile);

                string targetFile = ““;
                if (sourcefilename.Contains(“docx“))
                {
                    targetFile = destFolder + sourcefilename.Substring(0 sourcefilename.Length - 4) + “pdf“;
                }
                else
                {
                    targetFile = destFolder + sourcefilename.Substring(0 sourcefilename.Length - 3) + “pdf“;
                }

                if (File.Exists(targetFile))
                {
                    MessageBox.Show(“保存文件已存在,请重新选择保存位置!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
                    return;
                }

                try
                {
                    //读取word文档
                    Aspose.Words.Document doc = new Aspose.Words.Document(sourceFile);
                    doc.Save(targetFile Aspose.Words.SaveFormat.Pdf);
                    MessageBox.Show(“转换成功!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Exclamation);
                }
                catch
                {
                    MessageBox.Show(“转换失败!“ “提示“ MessageBoxButtons.OK MessageBoxIcon.Error);
                }

            }
        }

        private void button2_Click(object sender EventArgs e)
        {
            string sourceFile = ““;
            using (var form = new OpenFileDialog())
            {
                form.Filter = “Excel Files (*.xls;*.xlsx)|*.xls;*.xlsx“;
                form.RestoreDirectory = true;
   

 属性            大小     日期    时间   名称
----------- ---------  ---------- -----  ----

    ..A..H.     38400  2019-05-06 09:07  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\.suo

     文件          0  2019-05-06 08:46  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\Server\sqlite3\db.lock

     文件       4096  2019-05-06 08:46  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\Server\sqlite3\storage.ide

     文件      32768  2019-05-06 08:46  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\Server\sqlite3\storage.ide-shm

     文件    2212472  2019-05-06 09:07  WindowsFormsApp1\.vs\WindowsFormsApp1\v15\Server\sqlite3\storage.ide-wal

     文件    9664512  2019-04-16 09:02  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Aspose.Cells.dll

     文件   19953360  2016-11-20 13:05  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Aspose.Slides.dll

     文件   11303936  2019-04-19 14:38  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\Aspose.Words.dll

     文件      19968  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.exe

     文件      40448  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\bin\Debug\WindowsFormsApp1.pdb

     文件       7887  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\Form1.cs

     文件       3473  2019-05-06 09:01  WindowsFormsApp1\WindowsFormsApp1\Form1.Designer.cs

     文件       6025  2019-05-06 09:01  WindowsFormsApp1\WindowsFormsApp1\Form1.resx

     文件       9073  2019-05-06 09:03  WindowsFormsApp1\WindowsFormsApp1\ModifyInMemory.cs

     文件        753  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferences.cache

     文件       6422  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\DesignTimeResolveAssemblyReferencesInput.cache

     文件          0  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CopyComplete

     文件         42  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.CoreCompileInputs.cache

     文件       1064  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.FileListAbsolute.txt

     文件        847  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csproj.GenerateResource.cache

     文件      44771  2019-05-06 08:54  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.csprojAssemblyReference.cache

     文件      19968  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.exe

     文件        180  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Form1.resources

     文件      40448  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.pdb

     文件        180  2019-05-06 09:04  WindowsFormsApp1\WindowsFormsApp1\obj\Debug\WindowsFormsApp1.Properties.Resources.resources

     文件        477  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\Program.cs

     文件       1330  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\Properties\AssemblyInfo.cs

     文件       2845  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\Properties\Resources.Designer.cs

     文件       5612  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\Properties\Resources.resx

     文件       1103  2019-05-06 08:46  WindowsFormsApp1\WindowsFormsApp1\Properties\Settings.Designer.cs

............此处省略19个文件信息

评论

共有 条评论