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)

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

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

Parameters

sourceFileName
The name of the file to copy.
destFileName
The name of the new file to copy to.

Exceptions

Exception Type Condition
ArgumentException sourceFileName or destFileName is an empty string ("") or contains only whitespaces.
ArgumentNullException sourceFileName or destFileName is a null reference (in Visual Basic Nothing).
IOException An error occurs, or the destination file already exists.
SecurityException The caller does not have the required permission.
FileNotFoundException sourceFileName 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 for the destination path.

See Also

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