CSharpTest.Net
CopyTo(String,Boolean) Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempFile Class > CopyTo Method : CopyTo(String,Boolean) Method

target
replace

Glossary Item Box

Copies the file content to the specified target file name

Syntax

Visual Basic (Declaration) 
Public Overloads Sub CopyTo( _
   ByVal target As String, _
   ByVal replace As Boolean _
) 
C# 
public void CopyTo( 
   string target,
   bool replace
)

Parameters

target
replace

Example

Library/Library.Test/TestTempFiles.cs

C#Copy Code
TempFile filea = new TempFile();

File.WriteAllText(filea.TempPath, "Test");
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

TempFile fileb = new TempFile();
Assert.AreNotEqual(filea.TempPath, fileb.TempPath);

filea.CopyTo(fileb.TempPath, true);
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath));

File.Delete(filea.TempPath);
Assert.IsFalse(File.Exists(filea.TempPath));

fileb.CopyTo(filea.TempPath);
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath));

filea.Dispose();
fileb.Dispose();
VB.NETCopy Code
Dim filea As New TempFile()

File.WriteAllText(filea.TempPath, "Test")
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

Dim fileb As New TempFile()
Assert.AreNotEqual(filea.TempPath, fileb.TempPath)

filea.CopyTo(fileb.TempPath, True)
Assert.AreEqual("Test", File.ReadAllText(fileb.TempPath))

File.Delete(filea.TempPath)
Assert.IsFalse(File.Exists(filea.TempPath))

fileb.CopyTo(filea.TempPath)
Assert.AreEqual("Test", File.ReadAllText(filea.TempPath))

filea.Dispose()
fileb.Dispose()

Requirements

Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7

See Also

Generated with Document! X 2011 by Innovasys