PathRemoveFileSpecPathRemoveFileSpec*
*Contents  *Index  *Topic Contents
*Previous Topic: PathRemoveExtension
*Next Topic: PathRenameExtension

PathRemoveFileSpec


BOOL PathRemoveFileSpec(
    LPTSTR pszPath
);

Removes the trailing file name and backslash from a path, if it has them.

pszPath
Address of the path from which to remove the file name.

Example:

#include <windows.h>
#include <iostream.h>
#include "Shlwapi.h"

void main( void )
{

    // Path to include file spec.
	char buffer_1[] = "C:\\TEST\\sample.txt"; 
	char *lpStr1;
	lpStr1 = buffer_1;

    // Print the path with the file spec.
	cout << "The path with file spec is          : " << lpStr1 << endl;
 
    // Call to "PathRemoveFileSpec".
	PathRemoveFileSpec(lpStr1);

	// Print the path without the file spec.
	cout << "\nThe path without file spec is       : " << lpStr1 << endl;

}
OUTPUT:
==================
The path with file spec is          : C:\TEST\sample.txt

The path without file spec is       : C:\TEST

Up Top of Page
© 1997 Microsoft Corporation. All rights reserved. Terms of Use.