NGWS SDK Documentation  

This is preliminary documentation and subject to change.
To comment on this topic, please send us email at ngwssdk@microsoft.com. Thanks!

File.Copy (String, String, Boolean)

Copies an existing file to a new file, allowing an existing file to be overwritten.

[Visual Basic]
Overloads Public Shared Sub Copy( _
   ByVal sourceFileName As String, _
   ByVal destFileName As String, _
   ByVal overwrite As Boolean _
)
[C#]
public static void Copy(
   string sourceFileName,
   string destFileName,
   bool overwrite
);
[C++]
public: static void Copy(
   String* sourceFileName,
   String* destFileName,
   bool overwrite
);
[JScript]
public static function Copy(
   sourceFileName : String,
   destFileName : String,
   overwrite : Boolean
);

Parameters

sourceFileName
The name of the file to copy.
destFileName
The name of the new file to copy to.
overwrite
true if the destination file is to be overwritten, false otherwise.

Exceptions

Exception Type Condition
ArgumentNullException sourceFileName or destFileName is a null reference (in Visual Basic Nothing).
ArgumentException sourceFileName or destFileName is an empty string ("") or contains only whitespaces.
IOException An error occurs or the destination file already exists and overwrite is false.
SecurityException The caller does not have the required permission.
FileNotFoundException sourceFileName or destFileName cannot be found.

Remarks

Copy is a static method while CopyTo is an instance method. For CopyTo, you must have created a File object, which stores the source file name. Copy allows the specifying of a source file name without having to create a File object.

Requirements

NGWS Runtime Security:

FileIOPermissionAccess Write permission required to the destination path.

See Also

File Class | File Members | System.IO Namespace | File.Copy Overload List