Click here to Skip to main content
15,896,329 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Convert the docx file into txt format.Which detect the line break in docx file and same write in txt file?HOW?
Posted
Comments
Maciej Los 23-Feb-15 7:56am    
When new paragraph is starting, then new break line is inserted ;)
NixonUposseen 30-Mar-17 1:45am    
You can use this C# Word's library to achieve that task in a very very simple manner, see the following:

// Load input file in DOCX format.
DocumentModel document = DocumentModel.Load("Sample.docx", LoadOptions.DocxDefault);

// Save output file in TXT format.
document.Save("Sample.txt", SaveOptions.TxtDefault);

Also the following article demonstrates how to manipulate (do various tasks) with DOCX files in C#.

1 solution

I believe the linebreak is the <w:br xmlns:w="#unknown" /> tag and you can use Environment.NewLine to write a line to the text file.

Note that plain text files don't behave in the same way as Word files so you can't do much in the way of formatting.

The following CodeProject articles may also help Show Word File in WPF[^] and Find Text in Word Documents[^]
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900