Skip to content

Commit d1be19d

Browse files
committed
Fix build on .NET Framework
1 parent f199646 commit d1be19d

File tree

2 files changed

+15
-3
lines changed

2 files changed

+15
-3
lines changed

README.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -31,7 +31,7 @@ You can also consider the following libraries for documents creation and manipul
3131

3232
### Requirements
3333

34-
- .NET 8, 9, 10 and .NET Framework 4.6.2 and higher are supported, but tests are mostly performed on .NET 8 and above.
34+
- Supported targets are .NET 8, 9, 10 and .NET Framework 4.6.2 (minimum netfx version still supported).
3535
- DocSharp.SystemDrawing is for Windows only (.NET Framework or net*-windows), as System.Drawing.Common is only supported on Windows; while DocSharp.ImageSharp is cross-platform for .NET 8+ (ImageSharp does not support .NET Framework).
3636

3737
### Usage

src/DocSharp.Epub/EpubToDocxConverter.cs

Lines changed: 14 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@
77
using System.Text.RegularExpressions;
88
using System.Threading.Tasks;
99
using System.Xml.Linq;
10-
using DocSharp.Xml;
10+
using DocSharp.Helpers;
1111
using DocumentFormat.OpenXml;
1212
using DocumentFormat.OpenXml.Packaging;
1313
using DocumentFormat.OpenXml.Wordprocessing;
@@ -96,6 +96,8 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
9696
tempDir += Path.DirectorySeparatorChar;
9797
try
9898
{
99+
if (Directory.Exists(tempDir))
100+
Directory.Delete(tempDir);
99101
Directory.CreateDirectory(tempDir);
100102
}
101103
catch (Exception ex)
@@ -106,8 +108,18 @@ public async Task BuildDocxAsync(Stream input, WordprocessingDocument targetDocu
106108
try
107109
{
108110
// Extract EPUB to temp directory
109-
ZipFile.ExtractToDirectory(input, tempDir, overwriteFiles: true);
111+
using (var zip = new ZipArchive(input, ZipArchiveMode.Read, leaveOpen: true))
112+
{
113+
zip.ExtractToDirectory(tempDir);
114+
}
115+
}
116+
catch (Exception ex)
117+
{
118+
throw new SystemException($"Unable to extract EPUB to the temp directory. This step is necessary for EPUB processing. Details: {ex.Message}");
119+
}
110120

121+
try
122+
{
111123
// Initialize document
112124
var mainPart = targetDocument.MainDocumentPart ?? targetDocument.AddMainDocumentPart();
113125
mainPart.Document ??= new Document();

0 commit comments

Comments
 (0)