DirectoryInfo source = new DirectoryInfo(@"c:\MyDir")
foreach (DirectoryInfo diSourceSubDir in source.GetDirectories()) {
//罩蠢滚这里判断diSourceSubDir根据diSourceSubDir.Name来决定放在哪个集合档银中。
}
#include <stdio.h>#include <memory.h>
#include <string>
int main()
{
char filename[32]
char outfile[32]
scanf("%s", filename)
FILE *fp=fopen(filename, "r"型和卜), *ofp=fopen(outfile, "w"卜穗)
return 0
}
一个简单的读取文棚虚件,你可以仿照这个来读你的文件
给出 临时工作文件名和路径,要查的文件夹路径和文件夹名。用 DOS 命令获文件名
#include <stdio.h>
#include <stdlib.h>
#define Buff_size 4096
FILE *fin
void main (int argc, char *argv[])
{
char current_dir[72], namelist[72],current_file_name[72]
char command[200]
int i,j,n=0
char *buff
buff = (char *) malloc( Buff_size * sizeof (char))
if (!buff) {
printf("\007No enough memory -- Can not alloc the Buff\n")
exit(2)
}
strcpy(namelist,"C:\\temp\\abc.lis") // 临时工作文件名槐键和路径
strcpy(current_dir, "运明厅D:\\zzz") //要查的文件夹路径和文件夹名
sprintf(command,"DIR/B/A-D %s >%s", current_dir, namelist)
system(command)
if ( (fin = fopen(namelist,"r") ) == NULL ) {
printf("\007Cann'旁隐t open work file: %s ", namelist)exit(1)
}
while ( fgets( current_file_name, 72, fin) !=NULL ) n=n+1
rewind(fin)
printf("\007total %d files\n",n)
for (i=0i<ni++){
if ( fgets( current_file_name, 72, fin) ==NULL) exit(0)
printf("%s",current_file_name)
}
exit(0)
}
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)