当前位置:网站首页>C#/VB. Net word to text
C#/VB. Net word to text
2022-06-23 22:54:00 【51CTO】
I believe you will often be in Word Writing articles in documents , But sometimes we need to Word Document conversion to txt Format . and txt Format compared to other formats ,
- Small volume 、 Simple and convenient storage
- txt The format is relatively simple , No poisoning
- txt Format is a common format for computers and many mobile devices
Today's article will begin with C#/VB.NET Code, for example , Explain in detail how to Word Turn into txt Format . Please read the following for details .
Program environment :
In this test , Introduce... Into the program Free Spire.Doc for .NET. Can be referenced by Spire.Doc.dll file :
Method 1: take Free Spire.Doc for .NET Download to local , decompression , install . After installation , Find the installation path BIN In folder Spire.Doc.dll. And then in Visual Studio Open in “ Solution explorer ”, Right click “ quote ”,“ Add reference ”, The local path BIN Under folder dll Add a reference to the program .
Method 2: adopt NuGet install . This can be done by 2 Methods of installation :
(1) Can be in Visual Studio Open in “ Solution explorer ”, Right click “ quote ”,“ management NuGet package ”, And then the search “Free Spire.Doc”, Click on “ install ”. Wait for the program installation to complete .
(2) Copy the following to PM Console installation .
Install-Package FreeSpire.Doc -Version 10.2.0
take Word To Text
- Create a Document example .
- Use Document.LoadFromFile() Method loading Word Sample document .
- Use Document.SaveToFile() Method to save the document as TXT file .
[C#]
using
System.
Data;
using
System.
Drawing;
using
System.
Text;
using
Spire.
Doc;
using
Spire.
Doc.
Documents;
namespace
ConsoleApplication2
{
class
Program
{
static
void
Main(
string[]
args)
{
// Create a new document .
Document
document
=
new
Document();
// Load instance document .
document.
LoadFromFile(
"NewSample1.docx");
string
result
=
"Result-WordToText.txt";
// Save the document .
document.
SaveToFile(
result,
FileFormat.
Txt);
}
}
}
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
- 22.
- 23.
- 24.
- 25.
- 26.
- 27.
【VB.NET】
Imports
System
.Data
Imports
System
.Drawing
Imports
System
.Text
Imports
Spire
.Doc
Imports
Spire
.Doc
.Documents
Namespace
ConsoleApplication2
Class
Program
Private
Shared
Sub
Main(
ByVal
args()
As
String)
' Create a new document .
Dim
document
As
Document =
New
Document
' Load instance document .
document
.LoadFromFile(
"NewSample1.docx")
Dim
result
As
String =
"Result-WordToText.txt"
' Save the document .
document
.SaveToFile(
result,
FileFormat
.Txt)
End
Sub
End
Class
End
Namespace
- 1.
- 2.
- 3.
- 4.
- 5.
- 6.
- 7.
- 8.
- 9.
- 10.
- 11.
- 12.
- 13.
- 14.
- 15.
- 16.
- 17.
- 18.
- 19.
- 20.
- 21.
design sketch :

Be careful : The document path generated in the code is VS programmatic Debug route , File paths can also be customized to other paths .
边栏推荐
- The old CVM of Tencent cloud is migrated to the new CVM, and the IP remains unchanged
- Mysql中的触发器定义及语法介绍
- The principle of async and await
- 蚂蚁集团自研TEE技术通过国家级金融科技产品认证
- C language picture transcoding for performance testing
- Tcapulusdb Jun · industry news collection
- Redis6.x.x build rediscluster cluster
- How to set up external links in website construction
- Low code technology
- Log4j has been exposed to a nuclear bomb level vulnerability, and the developer has fried the pot!
猜你喜欢
![[technical dry goods] the technical construction route and characteristics of zero trust in ant Office](/img/d1/ce999b9f72bbb8f692c4298b4042aa.png)
[technical dry goods] the technical construction route and characteristics of zero trust in ant Office

C#/VB.NET Word转Text

為什麼你的數據圖譜分析圖上只顯示一個值?

PHPMailer 发送邮件 PHP

Section 30 high availability (HA) configuration case of Tianrongxin topgate firewall

解密抖音春节红包背后的技术设计与实践

混沌工程,了解一下

游戏安全丨喊话CALL分析-写代码

专业“搬砖”老司机总结的 12 条 SQL 优化方案,非常实用!

在宇宙的眼眸下,如何正确地关心东数西算?
随机推荐
How to create a virtual server through a fortress machine? What are the functions of the fortress machine?
Flutter Utils
应用实践 | Apache Doris 整合 Iceberg + Flink CDC 构建实时湖仓一体的联邦查询分析架构
What server is used for website construction? What is the price of the server
How to use fortress remote server two types of Fortress
FTP server setup setting website information can I set up FTP myself
蚂蚁获FinQA竞赛冠军,在长文本数值推理AI技术上取得突破
Change sql- Tencent cloud database tdsql elite challenge - essence Q & A
PHPMailer 发送邮件 PHP
What are the processes, levels, stages and key points of requirements analysis in software development
December 14, 2021: rebuild the queue according to height. Suppose there's a bunch of people out of order
Introduction to tcapulusdb lossless relocation
CS1.6 service startup tutorial
SQL语句中EXISTS的详细用法大全
How to use data warehouse to create time series
Save: software analysis, verification and test platform
Flush cache clear
C#/VB.NET Word转Text
How to set secondary title in website construction what is the function of secondary title
VNC multi gear resolution adjustment, 2008R2 setting 1280 × 1024 resolution