Skip to content

Commit 767feb4

Browse files
ES-944814-DocIO_fileformat_checker
1 parent 9b91872 commit 767feb4

File tree

4 files changed

+97
-0
lines changed

4 files changed

+97
-0
lines changed
Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,25 @@
1+
2+
Microsoft Visual Studio Solution File, Format Version 12.00
3+
# Visual Studio Version 16
4+
VisualStudioVersion = 16.0.31911.196
5+
MinimumVisualStudioVersion = 10.0.40219.1
6+
Project("{FAE04EC0-301F-11D3-BF4B-00C04F79EFBC}") = "DocIO-fileformat-checker", "DocIO-fileformat-checker\DocIO-fileformat-checker.csproj", "{C17B90BC-F559-456B-B189-90B53FF6CDD4}"
7+
EndProject
8+
Global
9+
GlobalSection(SolutionConfigurationPlatforms) = preSolution
10+
Debug|Any CPU = Debug|Any CPU
11+
Release|Any CPU = Release|Any CPU
12+
EndGlobalSection
13+
GlobalSection(ProjectConfigurationPlatforms) = postSolution
14+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
15+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Debug|Any CPU.Build.0 = Debug|Any CPU
16+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.ActiveCfg = Release|Any CPU
17+
{C17B90BC-F559-456B-B189-90B53FF6CDD4}.Release|Any CPU.Build.0 = Release|Any CPU
18+
EndGlobalSection
19+
GlobalSection(SolutionProperties) = preSolution
20+
HideSolutionNode = FALSE
21+
EndGlobalSection
22+
GlobalSection(ExtensibilityGlobals) = postSolution
23+
SolutionGuid = {EF357FC6-E9E5-4E3C-B932-43F727BE1DE4}
24+
EndGlobalSection
25+
EndGlobal
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
<Project Sdk="Microsoft.NET.Sdk">
2+
3+
<PropertyGroup>
4+
<OutputType>Exe</OutputType>
5+
<TargetFramework>net8.0</TargetFramework>
6+
<RootNamespace>DocIO_fileformat_checker</RootNamespace>
7+
</PropertyGroup>
8+
9+
<ItemGroup>
10+
<PackageReference Include="Syncfusion.DocIO.Net.Core" Version="*" />
11+
</ItemGroup>
12+
13+
</Project>
Lines changed: 46 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,46 @@
1+
using Syncfusion.DocIO;
2+
using Syncfusion.DocIO.DLS;
3+
using System;
4+
using System.IO;
5+
6+
namespace DocIO_fileformat_checker
7+
{
8+
class Program
9+
{
10+
static void Main(string[] args)
11+
{
12+
// Get all files from the directory
13+
string[] files = Directory.GetFiles(Path.GetFullPath(@"Data/"));
14+
// Loop through each file in the directory
15+
foreach (string filePath in files)
16+
{
17+
using (FileStream inputStream = new FileStream(filePath, FileMode.Open, FileAccess.Read))
18+
{
19+
try
20+
{
21+
// Try to open the file using Syncfusion DocIO
22+
using (WordDocument doc = new WordDocument(inputStream, FormatType.Automatic))
23+
{
24+
// Successfully opened the document
25+
Console.WriteLine("Supported format" + filePath);
26+
}
27+
}
28+
catch (Exception ex)
29+
{
30+
// Check if the exception message matches the unsupported format message
31+
if (ex.Message.Contains("This file format is not supported"))
32+
{
33+
// If the file format is not supported, print it to the console
34+
Console.WriteLine("Unsupported format: " + filePath);
35+
}
36+
else
37+
{
38+
// If some other exception occurs, handle it
39+
Console.WriteLine($"Error opening file {filePath}: {ex.Message}");
40+
}
41+
}
42+
}
43+
}
44+
}
45+
}
46+
}
Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,13 @@
1+
Identify file formats not supported by DocIO
2+
----------------------------------------
3+
4+
DocIO supports Word 97-2003 and later versions, handling major Microsoft Word file formats, including DOC, DOCX, RTF, DOT, DOTX, and DOCM. If you use an older or unsupported format, convert it to a supported format to avoid errors. Otherwise, you will get this exception: **This file format is not supported**.
5+
6+
**To run this example**
7+
8+
* Download this project to a location in your disk.
9+
* Create a folder **Data** parallelly to .sln file.
10+
* Add the input documents to the "Data" folder.
11+
* Run the application.
12+
13+
The console output will indicate whether the provided input document is supported or unsupported. If the document is unsupported, convert it to a format supported by DocIO.

0 commit comments

Comments
 (0)