Spire.Doc is a professional Word .NET library specifically designed for developers to create, read, write, convert and print Word document files. Get free and professional technical support for Spire.Doc for .NET, Java, Android, C++, Python.

Tue Feb 20, 2024 10:55 pm

Using Visual Studio 2022 Community
trying to convert a doc to a txt file
using version 9.4 of spire doc

Document doc = new Document();

if (File.Exists(FileName.Text))
{
doc.LoadFromFile(FileName.Text);
doc.SaveToFile("results.txt", FileFormat.Txt);

doc.Close();
}
the line doc.SaveToFile("results.txt", FileFormat.Txt); fails because FileFormat.Txt doesnt exist in the enum. What am I missing?

carlmosley0
 
Posts: 1
Joined: Tue Feb 20, 2024 2:00 pm

Wed Feb 21, 2024 7:14 am

Hi,

I hope this message finds you well. I am reaching out in response to the issue you encountered while trying to convert a .doc file to a .txt file using Spire.Doc version 9.4 in Visual Studio 2022 Community.

Upon testing the scenario with the environment and version you specified, I can confirm that the FileFormat.Txt enum value does exist. To address the problem you faced, I recommend creating a new project and ensuring that the necessary packages are properly imported. Subsequently, you can retest the conversion process to see if the issue persists.

Additionally, I would like to suggest an alternative method for saving the document directly to a .txt file using the following code snippet:

Code: Select all
doc.SaveToTxt("sample.txt", Encoding.UTF8);

I encourage you to try this alternative approach and verify if it meets your requirements. Should you encounter any further difficulties or have any questions, please do not hesitate to reach out to us promptly for assistance.

Best regards,
Triste
E-iceblue support team
User avatar

Triste.Dai
 
Posts: 1000
Joined: Tue Nov 15, 2022 3:59 am

Return to Spire.Doc

cron