Share via


PathUtil.SafeGetExtension(String) Method

Definition

Return the extension of the specified path string. This always returns a non-null string for the extension. It will return Empty if:

*   <code data-dev-comment-type="paramref">path</code> is null 
*   <code data-dev-comment-type="paramref">path</code> is empty
*   <code data-dev-comment-type="paramref">path</code> does not contain an extension

Otherwise, path's extension (including the period ".").

public:
 static System::String ^ SafeGetExtension(System::String ^ path);
public:
 static Platform::String ^ SafeGetExtension(Platform::String ^ path);
 static std::wstring SafeGetExtension(std::wstring const & path);
public static string SafeGetExtension (string path);
static member SafeGetExtension : string -> string
Public Function SafeGetExtension (path As String) As String

Parameters

path
String

The path from which to get the extension

Returns

The extension, or Empty if the extension could be not obtained

Remarks

This always returns a non-null string for the extension. It will return the empty string if:

  • path is null

  • path contains invalid path characters

  • path is empty

  • path does not contain an extension

Otherwise, path's extension (including the period ".").

Applies to