在VS2005中搜索目录和子目录中的文件 [英] To search files in a directory and subdirectories in VS2005
本文介绍了在VS2005中搜索目录和子目录中的文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想知道你们中的任何人是否可以发布诸如此类的示例
-读取目录中所有文件和子目录的名称
-打印当前目录名称
-打印文件大小
-在给定目录中搜索文件
我尝试了链接 Windows SDK文件系统:如何在目录和子目录中搜索文件? [ ^ ]在Visual C ++中效果很好6.0,但在VS2005中出现相同代码的错误
I was wondering if any of you could post some examples for things like
- reading in the names of all the files and subdirectories in a directory
- printing the current directory name
- printing file sizes
- Searching for a file ina given directory
i tried the link Windows SDK File System: How to search for files in a directory and subdirectories?[^] it works good in visual C++ 6.0 but i got errors for the same code in VS2005
推荐答案
该示例在VS2010上有效.将您的项目设置为处理UNICODE当然会出现问题,并且您将需要以下之一:
1.在所有字符串文字前加上大写字母L(L"text"),然后将std :: string更改为std :: wstring.
2.更改项目设置以处理MBCS而不是UNICODE.
3.通过明确说明所需的碰撞功能版本来强制使用MBCS.
我建议你去1号.
只是一个猜测,因为代码似乎是正确的.
The example works on VS2010. Setting your project to handle UNICODE will of course present a problem, and you would need one of the following:
1. Precede all string literals with a capital L (L"text"), and change std::string to std::wstring.
2. Change you project settings to handle MBCS instead of UNICODE.
3. Force use of MBCS by explicitly stating which version of the clashing functions you want.
I recommend you go for number 1.
Just a guess, since the code seems to be correct.
编译时是否收到任何警告,可能与不推荐使用的函数有关?
Did you get any warnings when you compiled it, possibly regarding deprecated functions?
这篇关于在VS2005中搜索目录和子目录中的文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文