Link to home
Start Free TrialLog in
Avatar of Sara Wilson
Sara Wilson

asked on

Reading binary file size and copying it to a different folder

I am creating an executable C++ program that will automatically read the size of a file and if it stops changing, it will copy and move that file to a different folder.  I am relatively new at programming so am not sure how to pursue this program.  The file is a binary (.hst) file.  Thank you in advance.

Also I am using Microsoft Visual Studio 2010 and with it I am using C++ Win32 console development platform.
SOLUTION
Avatar of Bill Prew
Bill Prew

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Sara Wilson
Sara Wilson

ASKER

I bought the book Sams Teach yourself C++ by Siddhartha Rao and I have completed it till chapter 8.  In chapter 27 they teach how to use streams for input and output (so this chapter is still very advance for me). I am currently trying to find an example that will help me select a file of my choice and determine its length but I haven't been successful so far.  I definitely had the approach you stated in mind for me to get this to work.  I will give it a try and see if I can get it working using the link you suggested.  Thank you so much for your input I really appreciate it.
If you can, I suggest to upgrade to the last version of Visual Studio, since it support some very nice features that will help your developments a lot, such as filesystem library, chrono library, smart pointers (unique_ptr, shared_ptr), ownership and move semantic ect ect ...

Alternatively, you can install the boost Library via NuGet (the package manager Embedded within VS) wich will provide the libraries / class mentionned above.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
@Bill,
The link you posted doesn't look like ISO C++. Correct me if I'm wrong, but it looks to me like a non-portable Microsoft managed C++ version. In fact, the link has the words, ".NET Framework".

The book description refers to standard C++, which refers to the ISO C++ Standard.
https://www.amazon.com/One-Hour-Sams-Teach-Yourself/dp/0789757745/ref=pd_lpo_sbs_14_t_0/137-1193034-2383614?_encoding=UTF8&psc=1&refRID=YC8WQ7QK85XVDSRG5D5B
@Sara,
>> and if it stops changing
You better have some better requirements, since conceivably, if another program adds one byte at a time, say, once every few seconds, then your program could run for years until your diskspace runs out. If you don't have better requirements to cover this point, then you should make some reasonable assumptions.
The book description refers to standard C++, which refers to the ISO C++ Standard.
https://www.amazon.com/One-Hour-Sams-Teach-Yourself/dp/0789757745/ref=pd_lpo_sbs_14_t_0/137-1193034-2383614?_encoding=UTF8&psc=1&refRID=YC8WQ7QK85XVDSRG5D5B 
Hmm, by looking at the content, a book starting with C-style arrays, raw pointers before Standard Library, speaking about exceptions handling until very late (when it is tied to raw pointers), neglecting class semantic can't be a good one.

Raw pointers (and C-style arrays who usually decay to raw pointers) have many issues (safety, validity, ownership, exceptions ect ...) that are solved by Standard Library containers and smart pointers. Better learn that first.
>> I am relatively new at programming ...
>>  a book starting with C-style arrays, raw pointers before Standard Library, speaking about exceptions handling until very late (when it is tied to raw pointers), neglecting class semantic can't be a good one.

So what book do you recommend for this beginner?
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
ASKER CERTIFIED SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial