根据文件夹大小停止某进程
来源:互联网 发布:2017cctv网络春晚 编辑:程序博客网 时间:2024/06/06 04:14
#define SEARCHFILETYPE "*.*"
#define SYSCONFIG "config.ini"
int g_FileSize = 100;
int getFileSize(string &sFileName)
{
struct stat buf;
int iRet = stat(sFileName.c_str(), &buf);
if (iRet == -1)
return NULL;
return buf.st_size;
}
void getAllFileName(const string& directory, const string& extName){
_finddata_t fileInfo;
intptr_t hFile;
string filter = directory;
if(filter[filter.size()-1] != '//'){
filter.push_back('//');
}
filter += "*.";
filter += extName;
hFile = _findfirst(filter.c_str(),&fileInfo);
if(hFile == -1){
return;
}
do {
string name(fileInfo.name);
string filePath = directory +"\\"+ name;
//cout<<"file :"<<name<<endl;
//cout<<"filePath :"<<filePath<<endl;
int FileMaxSize=1024*1024*g_FileSize;//10M
int fSize=getFileSize(filePath);
//cout<<"fSize :"<<fSize<<endl;
if (fSize>FileMaxSize) //如果文件大小超过了10M,需要备份
{
cout<<"filePath :"<<filePath<<endl;
system("taskkill /f /im XXX.exe");
}
} while (_findnext(hFile,&fileInfo) == 0);
_findclose(hFile);
}
int _tmain(int argc, _TCHAR* argv[])
{
char buf[1000]="";
GetCurrentDirectory(1000,buf); //得到当前工作路径
char path[1024];
sprintf(path,"%s\\%s",buf,SYSCONFIG);
char dir[256];
GetPrivateProfileString(_T("config"), _T("TempPath"),_T(""), dir, 256, _T(path));
int sleeptime = GetPrivateProfileInt(_T("config"), _T("Sleep"),10000, _T(path));
g_FileSize = GetPrivateProfileInt(_T("config"), _T("FileMaxSize"),100, _T(path));
cout<<"TempPath :"<<dir<<endl;
cout<<"sleeptime :"<<sleeptime<<endl;
cout<<"FileMaxSize :"<<g_FileSize<<endl;
while(1)
{
getAllFileName(dir,SEARCHFILETYPE);
Sleep(sleeptime);
}
getchar();
return 0;
}
#define SYSCONFIG "config.ini"
int g_FileSize = 100;
int getFileSize(string &sFileName)
{
struct stat buf;
int iRet = stat(sFileName.c_str(), &buf);
if (iRet == -1)
return NULL;
return buf.st_size;
}
void getAllFileName(const string& directory, const string& extName){
_finddata_t fileInfo;
intptr_t hFile;
string filter = directory;
if(filter[filter.size()-1] != '//'){
filter.push_back('//');
}
filter += "*.";
filter += extName;
hFile = _findfirst(filter.c_str(),&fileInfo);
if(hFile == -1){
return;
}
do {
string name(fileInfo.name);
string filePath = directory +"\\"+ name;
//cout<<"file :"<<name<<endl;
//cout<<"filePath :"<<filePath<<endl;
int FileMaxSize=1024*1024*g_FileSize;//10M
int fSize=getFileSize(filePath);
//cout<<"fSize :"<<fSize<<endl;
if (fSize>FileMaxSize) //如果文件大小超过了10M,需要备份
{
cout<<"filePath :"<<filePath<<endl;
system("taskkill /f /im XXX.exe");
}
} while (_findnext(hFile,&fileInfo) == 0);
_findclose(hFile);
}
int _tmain(int argc, _TCHAR* argv[])
{
char buf[1000]="";
GetCurrentDirectory(1000,buf); //得到当前工作路径
char path[1024];
sprintf(path,"%s\\%s",buf,SYSCONFIG);
char dir[256];
GetPrivateProfileString(_T("config"), _T("TempPath"),_T(""), dir, 256, _T(path));
int sleeptime = GetPrivateProfileInt(_T("config"), _T("Sleep"),10000, _T(path));
g_FileSize = GetPrivateProfileInt(_T("config"), _T("FileMaxSize"),100, _T(path));
cout<<"TempPath :"<<dir<<endl;
cout<<"sleeptime :"<<sleeptime<<endl;
cout<<"FileMaxSize :"<<g_FileSize<<endl;
while(1)
{
getAllFileName(dir,SEARCHFILETYPE);
Sleep(sleeptime);
}
getchar();
return 0;
}
0 0
- 根据文件夹大小停止某进程
- php获取某文件夹的大小
- 统计某路径下所有文件夹大小
- linux 查看进程,停止进程
- 可以停止的进程
- VB停止进程
- 停止进程代码
- 停止Oracle进程
- linux卡机 停止进程
- sh 停止 进程
- 如何 停止node进程?
- 启动停止守护进程
- 如何 停止node进程?
- 【Tomcat】停止冗余进程
- Windows停止进程
- 文件夹共享服务自动停止
- 根据XML解压文件夹
- 根据随机数猜大小
- 食物链 种类并查集
- ubuntu安装和卸载软件
- Java反射机制的使用
- c# 时间格式化
- 对ARM的TrustZone理解
- 根据文件夹大小停止某进程
- 【DP】最大子数组Maximum Subarray
- Object类
- 摄像机标定
- VC++常用数据类型及其操作详解
- C#-format-填充字符串---ShinePans
- java快速排序
- js面试题
- Android常见错误