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

path

Glossary Item Box

Safely delete the provided file 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
TempFile file = new TempFile();

Assert.IsTrue(File.Exists(file.TempPath));
TempFile.Delete(file.TempPath);

Assert.IsFalse(File.Exists(file.TempPath));
file.Dispose();

//ignres bad paths:
TempFile.Delete("@~+_(!&($_~!(&*+_~&^%^|||&&&\\\\ THIS IS AN INVALID FILE NAME.*");
VB.NETCopy Code
Dim file As New TempFile()

Assert.IsTrue(File.Exists(file.TempPath))
TempFile.Delete(file.TempPath)

Assert.IsFalse(File.Exists(file.TempPath))
file.Dispose()

'ignres bad paths:
TempFile.Delete("@~+_(!&($_~!(&*+_~&^%^|||&&&\\ THIS IS AN INVALID FILE NAME.*")

Requirements

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

See Also

Generated with Document! X 2011 by Innovasys