Results for “Filesystem operations”
Small, practical examples. Search by task or narrow things down below.
Create a file only when it does not exist
C#: FileMode.CreateNew prevents accidental replacement of existing content.
C#✓ Tested
Create a file without overwriting an existing one
Python: Use exclusive creation mode and handle FileExistsError explicitly.
Python✓ Tested
Create a ZIP archive from a file
Python: Give a ZIP entry a relative archive name instead of exposing its source directory.
Python✓ Tested
Create and clean up a temporary file
Java: Create a unique file and remove it in finally even when the operation fails.
Java✓ Tested
Delete a known scratch file
C#: File.Delete ignores a missing file but still throws for other I/O failures.
C#✓ Tested
Delete a known temporary file if present
Java: deleteIfExists returns whether a file was removed and still reports other I/O errors.
Java✓ Tested
Delete only a named scratch file
PowerShell: Use LiteralPath and avoid recursive removal for a single known file.
PowerShell✓ Tested
Delete rows selected by a related table
SQL: A correlated EXISTS limits the delete to explicitly listed records.
SQL✓ Tested
Delete rows selected by a related table
SQL Server: A correlated EXISTS limits the delete to explicitly listed records.
SQL Server✓ Tested
Delete rows selected by a related table
Postgres: A correlated EXISTS limits the delete to explicitly listed records.
Postgres✓ Tested
Delete rows selected by a related table
SQLite: A correlated EXISTS limits the delete to explicitly listed records.
SQLite✓ Tested
Detect an invalid Date object
JavaScript: An invalid Date has a NaN time value.
JavaScript✓ Tested