Persist and remove a document¶
This operation covers Document's file-system write and delete lifecycle, including the destructive cascade from Dispose().
| Field | Value |
|---|---|
| Operation ID | OP-10 |
| Trigger | Caller invokes Document.Save(string destinationDirectory), Document.Delete(), or Document.Dispose() |
| Inputs | Destination directory (Save), or none (Delete/Dispose) |
| Outputs | File written to disk, or file removed; true/false from Delete |
| Primary components | PdfAPI.Core.Document.Save, Document.Delete, Document.Dispose |
| Entry point | PdfAPI.Core\Document.cs |
Steps¶
Save: setFilePathto{destinationDirectory}\{FileName}and write all bytes to that path. (BR-22)Savecomposes the path with a hard-coded\separator rather thanPath.Combine.*Delete: deleteFilePathwhen it exists and returntrue; swallow any exception and returnfalse. (BR-23)Dispose: callDelete(), so disposing a document removes its file from disk. (BR-24)
Process flow¶
The following diagram visualizes this operation's control flow.
flowchart TD
SaveStart(["Save(destinationDirectory)"]) --> SetPath["FilePath = dir\FileName"]
SetPath --> Write["Write all bytes"]
Write --> SaveDone([File persisted])
DeleteStart(["Delete()"]) --> Exists{FilePath exists?}
Exists -->|Yes| Del["File.Delete"]
Del --> True([Return true])
Exists -->|No| False1([Return false])
DisposeStart(["Dispose()"]) --> CallDelete["Call Delete()"]
CallDelete --> DisposeDone([File removed])
Failure and edge-case behavior¶
- Any exception during deletion (e.g., file locked, permission denied) is swallowed and reported as
falsewith no diagnostic (BR-23). - Disposing a
Documentobtained from a caller-owned source file destroys that file, sinceDispose()unconditionally deletes it (BR-24).
Note: Statements marked with
*were inferred from code structure, naming conventions, or contextual evidence where direct confirmation was not available in source artifacts.
Related documentation¶
Sources¶
PdfAPI.Core\Document.cs