| | |
do CopyFile() DeletFile() function throw exception?
Please support our C++ advertiser: Intel Parallel Studio Home
![]() |
I guess the best way to know is to test it!
Put a try block to catch all and enter an invalid file. See what happens?
Put a try block to catch all and enter an invalid file. See what happens?
•
•
Join Date: Oct 2008
Posts: 122
Reputation:
Solved Threads: 6
You could use the File::Exists to first check if that file exists and then it will not through an exception.
or
C++ Syntax (Toggle Plain Text)
String^ FileOne = "C:\\File1.txt"; String^ FileTwo = "C:\\File2.txt"; if( File::Exists(FileOne) { File::Copy(FileOne, FileTwo); }
or
C++ Syntax (Toggle Plain Text)
String^ FileOne = "C:\\File1.txt"; String^ FileTwo = "C:\\File2.txt"; if( File::Exists(FileOne) { try { File::Copy(FileOne, FileTwo); } catch(Exception^ Ex ) { MessageBox::Show("Something is wrong"); } }
Last edited by Liszt; May 16th, 2009 at 3:54 pm.
![]() |
Similar Threads
- Understanding exceptions (Java)
- throw exception (Java)
- Stuck: Exception Handling and reading text from file (Java)
- Throwing an Exception (C++)
- Custom exception - throw-delay (C++)
Other Threads in the C++ Forum
- Previous Thread: dynamic stack using vector strategy
- Next Thread: Ways to get a Computers "ID"
| Thread Tools | Search this Thread |
api application array arrays based beginner binary c++ c/c++ calculator char char* class classes code compile compiler console conversion count delete deploy desktop directshow dll download dynamic dynamiccharacterarray encryption error file forms fstream function functions game givemetehcodez google graph gui homeworkhelp iamthwee ifstream input int integer java lib linkedlist linker linux list loop looping loops map math matrix memory news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg simple sorting string strings struct temperature template templates test text text-file tree unix url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





