Knowledge baseExam Center
ENEnglish
Choose language13

CKTIS / C#

System.IO.Path: practical reference

System.IO.Path: practical reference: Path manipulates path syntax without accessing the file system.

Version: .NET API; verified on .NET 10.0.14

Syntax

System.IO.Path /* select a documented member or constructor */

Path manipulates path syntax without accessing the file system.

Use Combine, Join, and GetExtension instead of manually inserting separators.

Root, separator, and case rules are platform-specific, and normalization is not an authorization check.

GetExtension can return an empty string; invalid characters and lengths depend on the system and later operation.

The complete program actually uses System.IO.Path; its exact expected stdout is .json.

Examples

using System;
using System.Buffers;
using System.Collections.Concurrent;
using System.Collections.Frozen;
using System.Collections.Generic;
using System.Collections.Immutable;
using System.Diagnostics;
using System.Globalization;
using System.IO;
using System.Linq;
using System.Linq.Expressions;
using System.Reflection;
using System.Runtime.CompilerServices;
using System.Runtime.InteropServices;
using System.Text;
using System.Text.Json;
using System.Text.Json.Nodes;
using System.Text.Json.Serialization;
using System.Text.RegularExpressions;
using System.Threading;
using System.Threading.Channels;
using System.Threading.Tasks;
using Number = System.Int32;

Console.WriteLine(Path.GetExtension("report.json"));

Result

.json

The complete program actually uses `System.IO.Path`; its exact expected stdout is `.json`.

Sources