C#DOC批量转TXT工具
来源:互联网 发布:java 判断法定节假日 编辑:程序博客网 时间:2024/05/05 03:10
先上图:
本程序是偶利用一个下午的时间呕心沥血才搞定的,呵呵——!可以把某一路径下的doc文件全部转化为TXT文件,但是程序没有检索子目录,如有需要请参考源码修改!
本程序在win2008,vs2008下编译,如有需要编译好的程序者请留下email我如果有空的话会给你mail一个的。
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;
namespace doc2txt
{
public partial class Form1 : Form
{
string[] fs;
public Form1()
{
InitializeComponent();
}
private void button1_Click(object sender, EventArgs e)
{
string _path;
fldDlg.ShowDialog();
_path = fldDlg.SelectedPath;
if (!Directory.Exists(_path)) return;
textBox1.Text = _path;
fs = Directory.GetFiles(_path, "*.doc");
foreach (string f in fs)
{
textBox2.AppendText(f + "/r/n");
}
}
private void button2_Click(object sender, EventArgs e)
{
Word.Application oWord = new Word.Application();
object vOpt = System.Reflection.Missing.Value;
try
{
textBox2.Text = "";
foreach (string of in fs)
{
object f = (object)of;
Word.Document vDoc = oWord.Documents.Open(ref f, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt);
string txtf = of.Substring(0, of.Length - 3) + "txt";
if (File.Exists(txtf)) File.Delete(txtf);
object otxt = (object)txtf;
object saveFormat = Word.WdSaveFormat.wdFormatText;
vDoc.SaveAs(ref otxt, ref saveFormat, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt, ref vOpt);
vDoc.Close(ref vOpt, ref vOpt, ref vOpt);
textBox2.AppendText(of + " --> " + Path.GetFileName(txtf) + "/r/n");
}
MessageBox.Show("转化完成!");
}
catch (Exception ex)
{
MessageBox.Show(ex.Message);
}
finally
{
oWord.Quit(ref vOpt, ref vOpt, ref vOpt);
oWord = null;
}
}
}
}
- C#DOC批量转TXT工具
- VBA批量转换:docx转pdf、doc、rtf、txt以及doc转docx
- 文档格式批量转换(doc,txt,pdf等)
- linux 文档格式批量转换(doc,txt,pdf等)
- 文档格式批量转换(doc,txt,pdf等)
- doc-txt
- \doc\pt-doc.txt
- pdf转doc工具
- pdf转doc工具
- JACOB DOC转TXT高效代码
- pdf转txt或则doc(pdfBox)
- python doc word文件转txt、html
- ubuntu 下 如何将 doc 转 txt
- 使用C#操作Doc转Txt存数据库
- PHP实现HTML批量转TXT文件
- doc转pdf的工具 - CutePDF Writer
- pdf转doc工具solid pdfconvert 5.0
- docx转doc工具(软件)
- 求救
- 安装.net时,无法安装 FrontPage 2000 WEB 扩展客户端解决办法
- CSDN英雄大会归来感悟
- 吓人的vector(stl)
- 消息称MySQL创始人已向Sun提交辞呈
- C#DOC批量转TXT工具
- 240个jQuery实现AJAX插件
- 使用正则表达式的方式重写URL。
- 如果不爱,请收起你的暧昧!
- 网站截图的原理——从服务器端模拟客户端
- javascript显示时间(在div中)
- map 转 bean
- CSDN英雄会:年纪最大的参与者与最美的mm
- 如何修复被破坏的Foxpro数据库