CommonGetVerifiedPath Method

Resolves a candidate file path and confirms it stays within the supplied base directory, guarding against path-traversal. Throws when the path is missing, malformed, or escapes the permitted directory.

Namespace:  IAS
Assembly:  Common (in Common.dll) Version: 1.0.0.0 (1.0.0.0)
Syntax
public static string GetVerifiedPath(
	string baseDirectory,
	string candidatePath
)

Parameters

baseDirectory
Type: SystemString
The trusted root directory the path must stay within.
candidatePath
Type: SystemString
The candidate path to validate and canonicalize.

Return Value

Type: String
The candidate path, unchanged, once verified as canonical and under the base directory.
See Also