#include<iostream>
#include<stdlib.h>
#include<windows.h>
#include<fstream>
#include<stdio.h>
#include<vector>
#include<string>
#pragma comment (lib, "winmm.lib")
using namespace std;
void MainMenu()
{
printf("请选择操作\n");
printf("1.显示当前文件夹的所有文件\n");
printf("2.返回上一级\n");
printf("3.进入文件夹\n");
printf("4.进入指定文件夹\n");
printf("5.退出\n");
}
void ShowFileList(string filename)
{
WIN32_FIND_DATAA p;
vector<string> filelist;
HANDLE h = FindFirstFileA(filename.c_str(), &p);
filelist.push_back(p.cFileName);
while (FindNextFileA(h, &p))
{
filelist.push_back(p.cFileName);
if (filelist.back() == "." || filelist.back() == "..")
{
filelist.pop_back();
}
}
for (int i = 0; i < filelist.size(); i++)
{
cout << filelist[i] << endl;
}
}
void ShowLastFileList(string & filepath)
{
string filepath2 = filepath;
string tmp = "../";
tmp += filepath2;
filepath = tmp;
ShowFileList(tmp);
}
void ShowSelectFileList(string filepath)
{
string yourchoose;
cin >> yourchoose;
yourchoose += '/';
string filepath2 = filepath;
yourchoose += filepath2;
ShowFileList(yourchoose);
}
void case4(string filepath)
{
string filename;
cin >> filename;
filename += '/';
filename += filepath;
ShowFileList(filename);
}
int main()
{
string filepath;
filepath = "*.*";
string filePath = filepath;
while (1)
{
system("CLS");
MainMenu();
int n;
cin >> n;
switch (n)
{
case 1:
system("CLS");
ShowFileList(filePath);
system("pause");
break;
case 2:
system("CLS");
ShowLastFileList(filePath);
system("pause");
break;
case 3:
system("CLS");
ShowSelectFileList(filePath);
system("pause");
break;
case 4:
system("CLS");
case4(filepath);
system("pause");
break;
case 5:
exit(0);
break;
default:
break;
}
}
return 0;
}
机械节能产品生产企业官网模板...
大气智能家居家具装修装饰类企业通用网站模板...
礼品公司网站模板
宽屏简约大气婚纱摄影影楼模板...
蓝白WAP手机综合医院类整站源码(独立后台)...苏ICP备2024110244号-2 苏公网安备32050702011978号 增值电信业务经营许可证编号:苏B2-20251499 | Copyright 2018 - 2025 源码网商城 (www.ymwmall.com) 版权所有