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

path

Glossary Item Box

Safely delete the provided directory name

Syntax

Visual Basic (Declaration) 
Public Overloads Shared Sub Delete( _
   ByVal path As String _
) 
C# 
public static void Delete( 
   string path
)

Parameters

path

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