PathStripPath (shlwapi)
Last changed: anfortas.geo@yahoo.com-216.204.61.86

.
Summary
Removes the path portion of a fully qualified path and file.

C# Signature:

[DllImport("shlwapi.dll", CharSet=CharSet.Auto)]
static extern void PathStripPath([In,Out] StringBuilder pszPath);

VB Signature:

Declare Function PathStripPath Lib "shlwapi.dll" (TODO) As TODO

Notes:

This is similar, but not identical, to Path.GetFileName. If the input string ends with a directory, the directory is returned rather than nothing; for example, "C:\foo\" becomes "foo\", "C:" stays "C:".

Tips & Tricks:

Please add some!

Sample Code:

StringBuilder str = new StringBuilder(@"c:\dir1\file.txt");
PathStripPath(str);
// Result: str.ToString() == "file.txt"

Alternative Managed API:

Path.GetFileName

Documentation