namespace AIStudio.Tools.OpenXml; /// /// Opens the template of an Office document, such as a PowerPoint or a Word template. /// internal static class TemplateFile { /// /// How a template file is opened for reading. /// /// /// Other programs may go on writing or deleting the file meanwhile. PowerPoint and Word keep a /// file open for writing as long as they show it, and a template which is still open there has /// to be readable all the same. /// private const FileShare FILE_SHARE = FileShare.ReadWrite | FileShare.Delete; /// /// Opens the template file at the given path for reading. /// /// /// Throws when the file is missing or cannot be opened; the caller decides what the user hears /// about it. /// /// The path of the template file. /// The file, opened for reading. public static FileStream OpenRead(string path) => new(path, FileMode.Open, FileAccess.Read, FILE_SHARE); }