mirror of
https://github.com/ajisaacs/OpenNest.git
synced 2026-11-12 05:31:09 -05:00
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>
21 lines
643 B
C#
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
|
|
);
|
|
}
|
|
}
|