CString CMp3playerDlg::GetFileName(CString path)
{
int nLen=0,p=0,q=0;
CString temp,result; temp=path;
char ch='A';
nLen=temp.GetLength();
while(true)
{
p=temp.Find(_T('\'));
if(p>=0)
{
q=pos;
temp.SetAt(p,ch);
}
else
break;
}
result=temp.Right(nLen-q);
return result;
}
C:\Documents and Settings\asd\桌面\Mp3Player\mp3playerDlg.cpp(70) : error C2001: newline in constant
C:\Documents and Settings\asd\桌面\Mp3Player\mp3playerDlg.cpp(70) : fatal error C1057: unexpected end of file in macro expansion
Error executing cl.exe.请问是怎么回事呢?
PS:我事想这样获得文件名,path是文件目录,挺笨的办法
有什么更方便的方法麻烦大家告诉我
{
int nLen=0,p=0,q=0;
CString temp,result; temp=path;
char ch='A';
nLen=temp.GetLength();
while(true)
{
p=temp.Find(_T('\'));
if(p>=0)
{
q=pos;
temp.SetAt(p,ch);
}
else
break;
}
result=temp.Right(nLen-q);
return result;
}
C:\Documents and Settings\asd\桌面\Mp3Player\mp3playerDlg.cpp(70) : error C2001: newline in constant
C:\Documents and Settings\asd\桌面\Mp3Player\mp3playerDlg.cpp(70) : fatal error C1057: unexpected end of file in macro expansion
Error executing cl.exe.请问是怎么回事呢?
PS:我事想这样获得文件名,path是文件目录,挺笨的办法
有什么更方便的方法麻烦大家告诉我
DoModal Displays the dialog box and allows the user to make a selection.
GetPathName Returns the full path of the selected file.
GetFileName Returns the file name of the selected file.
GetFileExt Returns the file extension of the selected file.
GetFileTitle Returns the title of the selected file.
要改成
p=temp.Find(_T('\\'));
CString result;
nLen=path.GetLength();
q = path.ReverseFind(_T('\\'));
result=path.Right(nLen - q - 1);
return result;
CString strFilename;
LPTSTR lpszFilename=strFilename.GetBuffer(_MAX_PATH);
memset(lpszFilename,0,_MAX_PATH);
lstrcpyn(lpszFilename,str,_MAX_PATH);
PathStripPath(lpszFilename);
strFilename.ReleaseBuffer();
包含头文件shlwapi.h
链接库文件shlwapi.lib
#pragma comment(lib,"shlwapi.lib")