Thread: skipping empty files using ifstream

Hybrid View

Previous Post Previous Post   Next Post Next Post
  1. #1
    Registered User
    Join Date
    Jul 2005
    Posts
    16
    it is in C++ programming.

  2. #2
    Banned
    Join Date
    Jun 2005
    Posts
    594
    that is c++

  3. #3
    Registered User
    Join Date
    Jul 2005
    Posts
    16
    im not sure i understand what you have there. The .htm file, can it be replaced by any extension like .txt. what exactly does the stat() function do...

  4. #4
    Banned
    Join Date
    Jun 2005
    Posts
    594
    it find the fiel size why dont you run that, and yea
    you coudl use any char array, or you can use
    string wtih .c_str() on the end so that you can cycle thru the
    name you find in a loop, and then do a statment like

    if filesize > 0 do this

  5. #5
    Registered User Tonto's Avatar
    Join Date
    Jun 2005
    Location
    New York
    Posts
    1,465
    Well if you want to strict fstream and such, you can like;

    Code:
    ifstream filehandle("your text files", ios::in | ios::binary  |ios::ate);
    size = filehandle.tellg();
    Then test size-1 against 0. And I'm sure you could read() or get() from the stream and test for an immediate EOF and get the same effect. According to MSDN we and the CRT have ourselves a filelength function defined in io.h, dunno, and can be read about here: http://msdn.microsoft.com/library/de...elengthi64.asp and then of course if we are limiting ourselves to windows you can use the GetFileSize[Ex] function.

Popular pages Recent additions subscribe to a feed

Similar Threads

  1. Program Deployment and DLL/OCX Files?
    By dfghjk in forum C++ Programming
    Replies: 5
    Last Post: 06-16-2008, 02:47 AM
  2. accessing all files in a folder.
    By pastitprogram in forum C++ Programming
    Replies: 15
    Last Post: 04-30-2008, 10:56 AM
  3. ifstream files
    By Stonehambey in forum C++ Programming
    Replies: 39
    Last Post: 03-12-2008, 01:51 PM
  4. Help with loading files into rich text box
    By blueparukia in forum C# Programming
    Replies: 3
    Last Post: 10-19-2007, 12:59 AM
  5. Using c++ standards
    By subdene in forum C++ Programming
    Replies: 4
    Last Post: 06-06-2002, 09:15 AM