CShanLingDlg *m_pdlg=(CShanLingDlg *)AfxGetApp()->m_pMainWnd; //CString strFilter = _T( "" ); CString strFilter = _T("All Files (*.*)|*.*|Chart Files (*.xlc)|*.xlc |Worksheet Files (*.xls)|*.xls |Data Files (*.xlc;*.xls)|*.xlc; *.xls||"); //m_pdlg->m_down.KillTimer(1); //CFileDialog fileDlg( TRUE, NULL, NULL, OFN_HIDEREADONLY, strFilter, this ); CFileDialog* fileDlg = new CFileDialog( TRUE, NULL, NULL, OFN_HIDEREADONLY, strFilter, this ); CString strTitle = _T ( "文件目录" ); fileDlg->m_ofn.lpstrTitle = strTitle.GetBuffer(10); if( fileDlg->DoModal() == IDOK ) { //获取文件属性 CFileStatus filestatus; CFile::GetStatus(fileDlg->GetPathName(),filestatus); //sprintf(m_File.filename,"%s",fileDlg->GetFileName()); sprintf(m_File.filename,"%s",fileDlg->GetFileTitle()); //AfxMessageBox(m_File.filename); //sprintf(file.fileuser,"%s",m_pdlg->m_username); //file.filesize=itoa(filestatus.m_size); itoa(filestatus.m_size,m_File.filesize,10); /******************************************************************************************/ //获取文件类型 //char fileext[10]=fileDlg->GetFileExt().GetBuffer(sizeof(fileDlg->GetFileExt())); char fileext[10]; sprintf(fileext,"%s",fileDlg->GetFileExt()); if ((!strcmp(fileext,"txt"))) sprintf(m_File.filetype,"%s","txt"); else if (!strcmp(fileext,"doc")) sprintf(m_File.filetype,"%s","doc"); else if (!strcmp(fileext,"docx")) sprintf(m_File.filetype,"%s","docx"); else if (!strcmp(fileext,"pdf")) sprintf(m_File.filetype,"%s","pdf"); else if (!strcmp(fileext,"rar")) sprintf(m_File.filetype,"%s","rar"); else if((!strcmp(fileext,"jpg"))) sprintf(m_File.filetype,"%s","jpg"); else if (!strcmp(fileext,"gif")) sprintf(m_File.filetype,"%s","gif"); else if (!strcmp(fileext,"bmp")) sprintf(m_File.filetype,"%s","bmp"); else if ((!strcmp(fileext,"swf"))) sprintf(m_File.filetype,"%s","swf"); else if (!strcmp(fileext,"avi")) sprintf(m_File.filetype,"%s","avi"); else if (!strcmp(fileext,"mpeg")) sprintf(m_File.filetype,"%s","mpeg"); else if (!strcmp(fileext,"rmvb")) sprintf(m_File.filetype,"%s","rmvb"); else if (!strcmp(fileext,"mov")) sprintf(m_File.filetype,"%s","mov"); else if (!strcmp(fileext,"mp4")) sprintf(m_File.filetype,"%s","mp4"); else if (!strcmp(fileext,"MPG")) sprintf(m_File.filetype,"%s","MPG"); else if ((!strcmp(fileext,"cmf"))) sprintf(m_File.filetype,"%s","cmf"); else if (!strcmp(fileext,"mp3")) sprintf(m_File.filetype,"%s","mp3"); else if (!strcmp(fileext,"cda")) sprintf(m_File.filetype,"%s","cda"); else if (!strcmp(fileext,"mid")) sprintf(m_File.filetype,"%s","mid"); else if (!strcmp(fileext,"wav")) sprintf(m_File.filetype,"%s","wav"); else if (!strcmp(fileext,"asf")) sprintf(m_File.filetype,"%s","asf"); else sprintf(m_File.filetype,"%s","其他文件"); /******************************************************************************************/ m_GridShare.InsertItem(0,""); m_GridShare.SetItemText(0, 0, m_File.filename); m_GridShare.SetItemText(0, 1, m_File.filesize); m_GridShare.SetItemText(0, 2, m_File.filetype); } else return; delete fileDlg;