开发环境 vs2010
扫描C盘的tmp文件扫描后把文件路径保存在txt文件里如果删除实现按路径删除
txt是unicode编码的,
#include "stdafx.h"
#include
#include
#include
#include
#include
using namespace std;
#define STR_SAVETEMPFILEINFO_FILENAME L"C:\alltemp.txt" // 用于存储垃圾文件信息的文件
int _tmain(int argc, _TCHAR* argv[])
{
_wsetlocale(LC_ALL,L"chs");
ifstream fs;
string line;
string temp;
int n = 0;
int num = 0;
//stringstream ss;
fs.open(STR_SAVETEMPFILEINFO_FILENAME, ifstream::binary);
if(!fs.is_open())
{
cout<<"不能打开文件"<<endl;
return 1;
}
while (getline(fs, line))
{
//ss.str(line);
n = line.rfind(':');
temp = line.substr(n+1);
cout<<temp<<endl;
}
getchar();
return 0;
}
部分运行结果:
我想用里面的路径 但是用不了都是空格 我已经用二进制的方式打开了 哪位大侠帮忙看下 谢谢了