file class : CopyTo(string,bool) method

Description

Copies a file.

Syntax

fileInstance.CopyTo(string path, bool overWrite)

Arguments

ClassNameDescription
stringpathPath of a file.
booloverWriteValue that indicates whether overwriting is allowed.

Return value

ClassDescription
fileAn instance that represents a file.

Sample code

1:

file f = new file("c:\somewhere...");

2:

file newFile = f.CopyTo("c:\newpath...", true); // The overwriting is allowed.

Notes

It's a wrapper of the System.IO.FileInfo.CopyTo(String,Boolean) method.

If the second argument is true, it will overwrite the destination file even if it exists.

If the second argument is false, an exception will be raised if the destination file exists.

Links for reference

Copyright © Cooker All rights reserved.