从文件路径中(如:E:/projects/web/vcer/app/js/pageViewer.js)获取文件名等信息(如:pageViewer.js)
获取文件的名字,Ext表明是否包含后缀
- CString CUtil::GetFileTitleFromFileName(CString FileName, BOOL Ext)
- {
- int Where;
- Where = FileName.ReverseFind('//');
- if (Where == -1)
- Where = FileName.ReverseFind('/');
- CString FileTitle = FileName.Right(FileName.GetLength() - 1 - Where);
- if (!Ext)
- {
- int Which = FileTitle.ReverseFind('.');
- if (Which != -1)
- FileTitle = FileTitle.Left(Which);
- }
- return FileTitle;
- }
获取文件所在的路径:
- CString CUtil::GetFilePathFromFileName(CString FileName)
- {
- int Where;
- Where = FileName.ReverseFind('//');
- if (Where == -1)
- Where = FileName.ReverseFind('/');
- CString FilePath = FileName.Left(Where);
- return FilePath + '//';
- }