Improve company productivity with a Business Account.Sign Up


File List

Posted on 2000-02-28
Medium Priority
Last Modified: 2010-04-15
I need a small routine to grab a file list in a know directory and check the size of each file.  If the size is greater than 0KB, flag an error.

This routine will check error file being generated by a compiler.


I'm sorry,  the code is for DOS based systems.  I don't need anything fancy.  I just need somthing like

do {
    handle = open ("\\debug\\*.err");  /* need to open multiple files */
    fs = filelength(handle);
    if (fs == 0) {
while (/* still have files in directory*/);

No GUI can be used.  This executable will called from within a batch file.

Question by:kph1
LVL 86

Expert Comment

ID: 2565243
For what OS?

Author Comment

ID: 2565329
Edited text of question.
LVL 31

Expert Comment

ID: 2565547
Hi kph1,

If you call it from a batch file you could easily use batch command 'FOR', i.e.

FOR %i in ("\debug\*.err") do call MyCheckLength.exe %i

and make a application 'MyCheckLength.exe' which get's one filename and checks its size.

If you need to do it from a C program you should try to find something like _findfirst, _findnext and _findclose (cannot remember if these are the exact function names for DOS).

Choose an Exciting Career in Cybersecurity

Help prevent cyber-threats and provide solutions to safeguard our global digital economy. Earn your MS in Cybersecurity. WGU’s MSCSIA degree program was designed in collaboration with national intelligence organizations and IT industry leaders.

LVL 22

Accepted Solution

cookre earned 200 total points
ID: 2565810
char    TmpPath[256];
struct  find_t FileInfo;

if (0==DOSFindFirstFile(TmpPath,_A_NORMAL|_A_HIDDEN|_A_SYSTEM,&FileInfo))
   if (FileInfo.size==0) {Do error stuff}
   while (0==DOSFindNextFile(&FileInfo))
         if (FileInfo.size==0) {Do error stuff}
LVL 22

Expert Comment

ID: 2565823
Sorry 'bout that - get rid of the first right curly brace.

Author Comment

ID: 2565877
Thank you.

Featured Post

A proven path to a career in data science

At Springboard, we know how to get you a job in data science. With Springboard’s Data Science Career Track, you’ll master data science  with a curriculum built by industry experts. You’ll work on real projects, and get 1-on-1 mentorship from a data scientist.

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Summary: This tutorial covers some basics of pointer, pointer arithmetic and function pointer. What is a pointer: A pointer is a variable which holds an address. This address might be address of another variable/address of devices/address of fu…
Windows programmers of the C/C++ variety, how many of you realise that since Window 9x Microsoft has been lying to you about what constitutes Unicode ( They will have you believe that Unicode requires you to use…
The goal of this video is to provide viewers with basic examples to understand and use pointers in the C programming language.
The goal of this video is to provide viewers with basic examples to understand how to create, access, and change arrays in the C programming language.

606 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question