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

Glossary Item Box

Detatches this instance from the temporary directory and returns the temp directory's path

Syntax

Visual Basic (Declaration) 
Public Function Detatch() As String
C# 
public string Detatch()

Example

Library/Library.Test/TestTempFiles.cs

C#Copy Code
string path = new TempDirectory().Detatch();
using (Stream io = File.Create(Path.Combine(path, "temp")))
    TempDirectory.Delete(path);

Assert.IsTrue(Directory.Exists(path));

GC.Collect(0, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();

Assert.IsFalse(Directory.Exists(path));
VB.NETCopy Code
Dim path As String = New TempDirectory().Detatch()
Using io As Stream = File.Create(Path.Combine(path, "temp"))
    TempDirectory.Delete(path)
End Using

Assert.IsTrue(Directory.Exists(path))

GC.Collect(0, GCCollectionMode.Forced)
GC.WaitForPendingFinalizers()

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