I use in my code (c++) CopyFile and DeleteFIle do these fumctions throw exceptions? do I need to surround them with try and catch?:)

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?

You could use the File::Exists to first check if that file exists and then it will not through an exception.

String^ FileOne = "C:\\File1.txt";
String^ FileTwo = "C:\\File2.txt";

if( File::Exists(FileOne) 
{
	File::Copy(FileOne, FileTwo);
}

or

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");
	}
}
Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.