to reproduce:
- unzip the attached file
callAspose.Words.FileFormatUtil.DetectFileFormat
for the text file
expected to get Txt, but got Unknown
data_1000chars_Uknown.txt.zip (805 Bytes)
to reproduce:
Aspose.Words.FileFormatUtil.DetectFileFormat
for the text filedata_1000chars_Uknown.txt.zip (805 Bytes)
Based on your issue, it looks like Aspose.Words.FileFormatUtil.DetectFileFormat
is not detecting the text file correctly. The file extension .txt
is supported by Aspose.Words and typically supports plain text files. Here’s a step-by-step guide to troubleshoot this issue:
Unzip the attachment:
data_1000chars_Uknown.txt.zip
file to extract data_1000chars_Uknown.txt
.Call the method:
Aspose.Words.FileFormatUtil.DetectFileFormat("path_to_your_extracted_file");
The expected result is to detect the file format as “Txt,” but it is detected as “Unknown.”
Verify the File Content:
data_1000chars_Uknown.txt
contains plain text without any encoded data or corruption.Verify Aspose Product Version:
Check the File Path:
DetectFileFormat
method is accurate and accessible.Run a Simplified Code:
using Aspose.Words;
public class Program
{
public static void Main()
{
string filePath = "C:\\path_to_your_file\\data_1000chars_Uknown.txt";
Aspose.Words.FileFormatInfo formatInfo = FileFormatUtil.DetectFileFormat(filePath);
Console.WriteLine(formatInfo.FileFormat);
}
}
You can check out the following Youtube Video demonstrating how to use FileFormatUtil.DetectFileFormat
method with Aspose.Words.
For further details, please refer to the DetectFileFormat documentation on the Aspose website.
Please follow these steps and verify your setup. If the issue persists, you may want to contact Aspose support with more detailed information about your environment and the files used.
Should I ask anything further from you to better assist you with this issue?
the file can be opened with notepad / notepad++ without an issue.
@Buffer2018 Actually any file can be considered as TXT document, to properly detect TXT format it is required to exclude other formats. TXT is kind of “last resort format” for a file.
Even if FileFormatUtil.DetectFileFormat
cannot detect your document as TXT. You can load the document using the following code and it will be loaded as TXT:
Document doc = new Document(@"C:\Temp\in.txt");
Console.WriteLine(doc.OriginalLoadFormat);
i understand, but the functionality im looking here is to identify (with some kind of certainty) that a file contains text. the attached file is a plain UTF-8 text file, but still is detected as Unknown and not as Txt.
@Buffer2018
We have opened the following new ticket(s) in our internal issue tracking system and will deliver their fixes according to the terms mentioned in Free Support Policies.
Issue ID(s): WORDSNET-28484
You can obtain Paid Support Services if you need support on a priority basis, along with the direct access to our Paid Support management team.