Sometimes we would like to remove the trailing file name and backslash from a path. In the following, there are several different ways to make it and I am glad to share with you.
[1] MFC下的方法,使用CString类的ReserveFind、Left成员函数。
[2] C的方法,使用strrchr逆向字符串查找函数。
[3] C的方法,不适用库函数的方法,通过循环自己查找。
[4] 使用Windows的API的方法,PathRemoveFileSpec。
路径处理技巧:去除尾部文件名与反斜杠
本文介绍了几种不同的方法来移除路径中的尾部文件名及反斜杠,包括MFC、C语言、自定义循环以及Windows API等。详细步骤和示例代码帮助开发者轻松实现路径简化。
1086

被折叠的 条评论
为什么被折叠?



