#Include #Include #Include #Include #Include #Include Void

You might also like

Download as doc, pdf, or txt
Download as doc, pdf, or txt
You are on page 1of 3

// bai1.cpp : Defines the entry point for the console application.

//

#include "stdafx.h"
#include<windows.h>
#include<tchar.h>
#include<stdio.h>
#include<string.h>
#include<conio.h>

void lietke()
{
LARGE_INTEGER size;
WIN32_FIND_DATA find;
HANDLE file;
char ten[200];
int dem1=0;
printf(" bai liet ke cac file va thu muc:\n Nhap duong dan
thu muc: ");
fflush (stdin);
gets(ten);

if(ten[0]=='/') ten[0]'*');
else strcat(ten,"\\*");
file=FindFirstFileA(ten,&find);
if(file==INVALID_HANDLE_VALUE)
{
printf("\n khong co file:%s \n",ten);
}
else
{
Printf("\n noi dung tim kiem gom:\n");
if(find.dwFileAttributes &FILE_ATTRIBUTE_DIRECTORY) {}
else
{
dem1++;
size.lowpart=find.nFileSizeLow;
size.highpart=find.nFileSizeHigh;
printf("<file>:%s\t<size>:
%d\n",find.cFileName,size.QuadPart)
}
while(true)
{
if(FindNextFileA(file,&find)=false) break;
if(find.dwFileAttributes
&FILE_ATTRIBUTE_DIREXTORY) {}

else
{
dem1++;
size.lowpart=find.nFileSizeLow;
size.highpart=find.nFileSizeHigh;
printf("<file>:\t%s\t<size>:\t
%ld\n",find.cFileName,size.quadPart);
}
}
printf("\n co %d file \n",dem1);
}
}
void kichthuoc()
{
LARGE_INTEGER size;
WIN32_FIND_DATAA find;
HANDLE file;
char ten[100];
printf(" hien thi size of file:\n nhap duong dan
den file:");
fflush(stdin);
gets(ten);
file=FindFirstFileA(ten,&find);
if(file==INVALID_HANDLE_VALUE)
printf("\n khong co file %s",ten);
else
{
size.LowPart = find.nFileSizeLow;
size.HighPart = find.nFileSizeHigh;
printf("<file>%s<size>:%d byte
\n",ten,size.QuadPart );
}
}
void demfile()
{
int dem=0;
WIN32_FIND_DATAA find;
HANDLE file;
char ten[100];
printf(" bai dem so file trong thu muc
hiem tai: \n nhap duong dan:");
fflush(stdin);
gets(ten);
if(ten[0]=='/') ten[0]=(*.*);
else strcat(ten,"\\*.*");
file=FindFirstFileA(ten,&find);
if(file=INVALID_HANDLE_VALUE)

else
{
if(find.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY) {}
else dem++;
While(FindNextFileA(file,find))
{
if(find.dwFileAttributes
&FILE_ATTRIBUTE_DIRECTORY)
else dem++;
}
printf(" ket qua cho %d file \n",dem);
}

int _tmain(int argc, _TCHAR* argv[])


int main()
{ int n;
printf("\n nhap 1 de liet ke cac file va thu muc");
printf("\n nhap 2 de hien thi kich thuoc chuong trinh duoc
tao ra");
printf("\n nhap 3 de hien thi so file trong thu muc hien
tai");
printf("\n hay chon so de thuc thi thao tac tuong ung ");
scanf(%d,&n);
switch(n)
{
case1:lietke();
break;
case2:kichthuoc();
break;
case3:demfile();
break;
}
system("Pause");
return 0;
}

You might also like