Jack Klein said:
In the general case this can't be done using standard C++.
Of course, immediately terminating a program before it did anything at all
due to a lack of resources also constitutes conforming behavior of programs
created by a C++ compiler. ... or, put differently, the C++ standard does
not guarantee that a program created by a conforming implementation does
anything useful at all. Thus, there is actually nothing a C++ program can
do using standard C++.
Maybe this is not the best perspective on things? Sure, there are load of
things which can fail when trying to move file (on some systems, the file
being open causes the renaming to fail; on some systems 'rename()' may fail
to move between different partitions or devices; the destination may exist
or not readable; actually, there is no need for the existance of something
like a "file" at all; etc.). I doubt that "File.Move()" can cope with all
those errors...
If you want to move a file, 'rename()' is way to go. If this fails you
might want to try other approaches like copying and then removing (which
can, BTW, also be done using standard C++), etc.