CSharpTest.Net
Attach Method
See Also  Example Send Feedback Download Help File
CSharpTest.Net.Library Assembly > CSharpTest.Net.IO Namespace > TempDirectory Class : Attach Method

existingPath

Glossary Item Box

Attaches a new instances of a TempFile to the provided directory path

Syntax

Visual Basic (Declaration) 
Public Shared Function Attach( _
   ByVal existingPath As String _
) As TempDirectory
C# 
public static TempDirectory Attach( 
   string existingPath
)

Parameters

existingPath

Example

Library/Library.Test/TestTempFiles.cs

C#Copy Code
string path;
using (TempDirectory d = new TempDirectory())
{
    Assert.IsTrue(Directory.Exists(d.TempPath));
    path = d.Detatch();
}
Assert.IsTrue(Directory.Exists(path));
using (TempDirectory d = TempDirectory.Attach(path))
{
    Assert.IsTrue(Directory.Exists(path));
}
Assert.IsFalse(Directory.Exists(path));
VB.NETCopy Code
Dim path As String
Using d As New TempDirectory()
    Assert.IsTrue(Directory.Exists(d.TempPath))
    path = d.Detatch()
End Using
Assert.IsTrue(Directory.Exists(path))
Using d As TempDirectory = TempDirectory.Attach(path)
    Assert.IsTrue(Directory.Exists(path))
End Using
Assert.IsFalse(Directory.Exists(path))

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys