subject_14719.htm
来自「一些关于vc的问答」· HTM 代码 · 共 18 行
HTM
18 行
<p>
序号:14719 发表者:mmvr 发表日期:2002-09-10 19:25:42
<br>主题:问一个很菜的问题:如何通过用户输入的路径名得到该路径内部的信息?
<br>内容:我要做一个对话框,用户在combox内输入路径名,确认后在list中将该路径中的文件列出来,但是我不知道怎样才能得到诸如文件个数、文件名之类的信息,请指教。
<br><a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p>
<hr size=1>
<blockquote><p>
<font color=red>答案被接受</font><br>回复者:Wang Tao 回复日期:2002-09-11 08:44:26
<br>内容:DisplayPath(LPCTSTR strPath)<BR>{ <BR> //<BR> // Displaying the Path<BR> //<BR> int Dnumber=0; //number for your subdirectories<BR> int Fnumber=0; //number for your files<BR> CFileFind find;<BR> CString strPathFiles = strPath;<BR> BOOL bFind;<BR> CSortStringArray strDirArray;<BR> CSortStringArray strFileArray;<BR> if ( strPathFiles.Right(1) != "\\" )<BR> strPathFiles += "\\";<BR> strPathFiles += "*.*";<BR><BR> bFind = find.FindFile( strPathFiles );<BR><BR> while ( bFind )<BR> {<BR> bFind = find.FindNextFile();<BR> if ( find.IsDirectory() && !find.IsDots() )<BR> { <BR> strDirArray.Add( find.GetFilePath() );<BR> Dnumber++;<BR> }<BR> if ( !find.IsDirectory() && m_bFiles )<BR> {<BR> strFileArray.Add( find.GetFilePath() );<BR> Fnumber++;<BR> }<BR> }<BR> <BR> strDirArray.Sort();<BR> <BR> for ( int i = 0; i < strDirArray.GetSize(); i++ )<BR> {<BR> //do what ever you want to do with the directories<BR> }<BR><BR> strFileArray.Sort();<BR> for ( i = 0; i < strFileArray.GetSize(); i++ )<BR> {<BR> //do what ever you want to do with the files<BR> }<BR>}
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
<hr size=1>
<blockquote><p>
回复者:mmvr 回复日期:2002-09-11 17:22:21
<br>内容:多谢!!!
<br>
<a href="javascript:history.go(-1)">返回上页</a><br><a href=http://www.copathway.com/cndevforum/>访问论坛</a></p></blockquote>
⌨️ 快捷键说明
复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?