查询处理文件夹下的文件名称

1.查询处理文件夹下的文件名称:

long handle;//用于查找句柄
	CString srt;
	struct _finddata_t FileInfo;
	const char *to_search = "C:\\Users\\FuLiang-Yin\\Desktop\\www\\*.txt";
	handle = _findfirst(to_search, &FileInfo);//第一次查找
	
	int y = 0;
	if (-1 == handle)
	{
		MessageBox(L"没有找到匹配的项目\n");
	}
	else
	{
		srt = FileInfo.name;
		data1.push_back(srt);
		while (!_findnext(handle, &FileInfo))
		{
		  srt = FileInfo.name;
		  data1.push_back(srt);
		  y++;
		}
		for (int i=0;i<=y;i++)
		{
			DeleteFile(_T("C:\\Users\\FuLiang-Yin\\Desktop\\www\\") + data1[i]);
		}
		_findclose(handle);
	    data.push_back(y+1);
		srt.Format(_T("%d"), data[0]);
		y = 0;
		SetDlgItemText(IDC_SNUM, srt);//更新编辑框内容(主要是接收编辑框中的)
		MessageBox(L"已经处理完成"+ srt+"数据!");
	}

2.移动或者删除文件

	CStdioFile file;
	CString  Sat;
	BOOL B_bool = 1;
	for (int i=0;i<=3;i++)
	{
		file.Open(_T("C:\\Users\\FuLiang-Yin\\Desktop\\异常数据\\" + data1[i] + ".csv"), CFile::modeRead);

		CString str;
		int io = 0;
		int num = 0;
		CString substr[77];
		while (file.ReadString(str))
		{
			str = str.Trim(_T(" "));
			int count = 0;
			int index = str.Find(_T(","));
			while (index != -1 && count < 71)
			{
				substr[count++] = str.Left(index);
				str = str.Right(str.GetLength() - index - 1);
				index = str.Find(_T(","));
			}
			substr[count++] = str;

			Index = m_list1.InsertItem(0xffff, _T(""));
			int u = 59;
			for (int i = 0; i <= DT; i++)
			{
				m_list1.SetItemText(Index, i, substr[u]);
				u++;
			}
			if (substr[65] == " --------"|| substr[66]=="---- "|| substr[67] == " --------" || substr[68] == "---- "|| substr[69] == " --------" || substr[70] == "---- ")
			{
			//	m_list1.SetItemText(Index, DT, L"重复!");
				num++;
			}
			io++;
		}
		CString str11, str12;
		str11.Format(_T("%d"), io);
		str12.Format(_T("%d"), num);
		SetDlgItemText(IDC_STATIC1, str11);//更新编辑框内容(主要是接收编辑框中的)
		SetDlgItemText(IDC_STATIC2, str12);//更新编辑框内容(主要是接收编辑框中的)
		file.Close();
		if (num>10)
		{
			BOOL bMoveOK = MoveFile(_T("C:\\Users\\FuLiang-Yin\\Desktop\\异常数据\\" + Sat + ".csv"), _T("C:\\Users\\FuLiang-Yin\\Desktop\\异常数据1\\" + Sat + ".csv")); //移动文件
			if (bMoveOK)
				MessageBox(_T("移动成功!"), _T("Tip"), MB_OK);
			else
				MessageBox(_T("移动失败!"), _T("Tip"), MB_OK);
		}
		io = 0;
		num = 0;
		//MessageBox(_T("查询完成!"));
	}

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 1
    评论
评论 1
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值