FileUtility

References
public class FileUtility
This class maintains all information and functionality regarding document files.

Constructors

FileUtility

#
Construct a new document file state class.
public FileUtility(
document
Document that owns this instance.
)

Properties

AutoSaveFilePath

#
Gets the file path to the autosave file, or null if that's currently not possible.
public string AutoSaveFilePath { get; }

BackupMethod

#
Gets or sets the backup behaviour for this document.
public BackupMethod BackupMethod { get; set; }

BackupTimestamp

#
Gets or sets the timestamp formatting to be used when backing up files which are about to be overwritten due to a Save operation.
public string BackupTimestamp { get; set; }

BackupTimestampWithFallback

#
Gets the user overridden time stamp format, or the default if the value has not been overridden.
public string BackupTimestampWithFallback { get; }

BackupUserFolder

#
Gets or sets the backup folder for when the BackupMethod equals BackupMethod.UserFolder.
public string BackupUserFolder { get; set; }

Directory

#
Gets the directory of the current path, if any.
public string Directory { get; }

DisplayText

#
Gets the text used to describe this document. The DisplayText may contain the filename and the saved state, as well as hierarchical clues.
public string DisplayText { get; }

FallbackName

#
Gets or sets the fallback name. If the file is otherwise unsaved, the fallback name (if set) will be used instead of "unnamed".
public string FallbackName { get; set; }

FileName

#
Gets the filename (without the extension) of the current path, if any.
public string FileName { get; }

FileOverwriteWarning

#
When a warning is set, saving a file requires an additional mouse click. The warning is not serialised. Typically backup and autosave files will have this warning set to avoid them being summarily overwritten.
public string FileOverwriteWarning { get; set; }

HasPath

#
Gets a value indicating whether the file path has been set.
public bool HasPath { get; }

Path

#
Gets the filepath that this document is associated with. Not every document is associated with a file, so this field may be null or empty. Assigning a new path to a file does not trigger a save action.
public string Path { get; set; }

Thumbnail

#
Gets or sets the thumbnail image for this document. The getter is lazy: if no thumbnail has been assigned yet it will attempt to generate one via TryCreateThumbnail() on first access.
public Bitmap Thumbnail { get; set; }

Methods

AutoSave

#
Perform an autosave operation.
public AutoSaveResult AutoSave(
reason,
Reason for autosave.
processId
Id associated with request. Subsequent requests with identical IDs are ignored.
)

AutoSave

#
Perform an autosave operation.
public AutoSaveResult AutoSave()

CreatePreview

#
Create a preview image of the entire document at a fixed scale. Unlike TryCreateThumbnail(), the result is not fit-to-bounds; the bitmap is sized to the document's ObjectList.AttributeBounds multiplied by scale.
public Bitmap CreatePreview(
scale,
Render scale (1.0 for 100%, 2.0 for 200%, etc.).
padding = 10
Pixel padding around all four sides of the bitmap. May be negative to crop.
)
A new bitmap, or null if the document contains no laid-out objects.

DeleteAutoSaveFile

#
Try and remove the autosave file.
public bool DeleteAutoSaveFile()
True if a file was deleted.

PickNewSaveBackupFolder

#
Ask the user to specify a new folder location for the BackupUserFolder. This method must be called on the UI thread.
public bool PickNewSaveBackupFolder()
True if a new folder was picked, false if otherwise.

SpecifyNewTimestampFormat

#
Display the UI needed to set a new backup timestamping format.
public bool SpecifyNewTimestampFormat()
True if a new format was set.