| | |
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"
Views: 448 | Replies: 2
| Thread Tools | Search this Thread |
Tag cloud for C++
api application array arrays assignment based beginner binary c++ c/c++ calculator char char* class classes code coding compile compiler console conversion convert count data database delete deploy developer display dll dynamiccharacterarray email encryption error file format forms fstream function functions game generator givemetehcodez graph iamthwee ifstream image input int java lib list loop looping loops map math matrix memory multidimensional multiple newbie news number numbertoword output pointer problem program programming project python random read recursion recursive reference return rpg search sort sorting string strings struct template templates text tree url variable vector video visual visualstudio win32 windows winsock wordfrequency wxwidgets





