【小程序】findobj
来源:互联网 发布:程序员联合开发 编辑:程序博客网 时间:2024/05/04 16:06
为了方便开发,实验室的师哥给了一个小任务,写一个小程序,完成以下功能:给一个txt文档,里面有一些文件名,这些文件是要求找出的;给一个目录路径,里面可能包含这个txt中指定的文件(也可能没有);如果某个文件存在就把它复制到另一个指定文件夹里面。
写了一个80来行的程序,程序木有界面,缺点是不能遍历指定文件夹中的嵌套文件夹。
#include<stdio.h>#include<stdlib.h>#include<string.h>#include<io.h>char tFPath[60];char dFPath[20];bool findFiles(char *fileName){long Handle;struct _finddata_t FileInfo;char path[60];strcpy(path,tFPath);strcat(path,"\\");strcat(path,fileName);printf("path == %s\n",path);if((Handle=_findfirst(path,&FileInfo))==-1L){printf("sorry, no such file!\n");return false;}else{printf("Find it:%s\n",FileInfo.name);char SysOrder[100]="copy ";strcat(SysOrder,path);strcat(SysOrder," ");strcat(SysOrder,dFPath);system(SysOrder);_findclose(Handle);return true;}return true;}int main(){FILE *fp=NULL;char fileName[30];char a;char txtSrc[30];printf("Please enter the TXT Source file path:\n");scanf("%s",txtSrc);fp=fopen(txtSrc,"r");printf("Please enter the target folder path:\n");scanf("%s",tFPath);printf("Please enter the destination folder path:\n");scanf("%s",dFPath);int i=0;do{a=fgetc(fp);if (a!='\n')fileName[i++]=a;else{fileName[i]='\0';findFiles(fileName);i=0;}}while(a!=EOF);fclose(fp);getchar();return 0;}
0 0
- 【小程序】findobj
- findobj
- findobj函数小记
- matlab的findobj函数
- obj type using in findobj
- 重写findobj【可以遍历子文件夹】
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- 小程序
- Nginx+PHP在Windows平台上的搭建
- PHP中的$_SERVER['PATH_INFO']
- 友善卡片电脑开用第一步(安卓)
- HDU4772-Zhuge Liang's Password
- 电子邮件营销增效技巧揭秘
- 【小程序】findobj
- 和小白一起学ABAP -- 6 从菜鸟到大神
- Swift语言官方文档翻译(4)-Basic Operators
- LoggerTest
- smtp 发邮件
- 基于hadoop2.2的namenode与SecondaryNameNode分开配置在不同的计算机
- Ubuntu安装星际译王辞典
- 安装SQL SERVER 2008出现 RebootRequiredCheck Fail 问题解决
- TinyXML 中文指南