Files
OpenNest/OpenNest.IO/SharedFile.cs
T
ajandClaude Opus 5.5 5668952e6b fix(import): read source drawings that are open in another program
AutoCAD keeps an open DWG/DXF locked for writing, and ACadSharp's path
constructors (and File.OpenRead / XmlReader.Create) deny write sharing,
so the CAD Converter could not import a part while it was open in
AutoCAD. Open source files read-only with read/write sharing instead.

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
2026-11-09 14:01:56 -05:00

21 lines
643 B
C#

using System.IO;
namespace OpenNest.IO
{
/// <summary>
/// Opens source drawings read-only without blocking, or being blocked by, the program
/// that has them open: AutoCAD keeps an open DWG/DXF locked for writing, and a reader
/// that denies write sharing (the <see cref="File.OpenRead"/> default) fails on it.
/// </summary>
internal static class SharedFile
{
public static FileStream OpenRead(string path) =>
new FileStream(
path,
FileMode.Open,
FileAccess.Read,
FileShare.ReadWrite | FileShare.Delete
);
}
}