FIND YOUR NEXT FEW LINES

Results for “File operations & archives”

Small, practical examples. Search by task or narrow things down below.

947 snippets foundClear filters
C#File operations & paths

Read a filename stem and extension

C#: Use Path helpers instead of splitting a path on dots or directory separators.

C#✓ Tested
C++Filesystem operations

Read the byte size of a regular file

C++: file_size reads filesystem metadata without loading file contents.

C++✓ Tested
PowerShellFile operations & integrity

Rename a file in its current directory

PowerShell: Rename-Item changes the name without moving the item to another directory.

PowerShell✓ Tested
C++Filesystem operations

Rename a known file through filesystem

C++: filesystem::rename reports an error by exception when the operation fails.

C++✓ Tested
JavaFile operations & binary data

Visit files recursively

Java: Close the stream returned by Files.walk and sort relative paths for stable output.

Java✓ Tested
PowerShellFile operations & integrity

Append a line while keeping earlier content

PowerShell: Add-Content appends using an explicitly selected encoding.

PowerShell✓ Tested
C++Filesystem operations

Calculate a lexical relative path

C++: lexically_relative compares path components without requiring the paths to exist.

C++✓ Tested
JavaFile operations & binary data

Load a small properties configuration

Java: Use a Reader to make the configuration character encoding explicit.

Java✓ Tested
JavaFile operations & binary data

Normalize relative path components

Java: Path.normalize removes redundant dot components without accessing the filesystem.

Java✓ Tested
C#File operations & paths

Replace a path extension

C#: Path.ChangeExtension transforms a path string without moving or creating a file.

C#✓ Tested
C++Filesystem operations

Set owner-only read and write permissions

C++: Replace ordinary permission bits with the requested owner permissions.

C++✓ Tested
JavaFile operations & binary data

Write and read binary bytes

Java: Use the byte-oriented Files methods when text encoding should not be involved.

Java✓ Tested