Visual Basic (Declaration) | |
---|---|
Public Shared Function Attach( _ ByVal existingPath As String _ ) As TempFile |
C# | |
---|---|
public static TempFile Attach( string existingPath ) |
Parameters
- existingPath
Library/Library.Test/TestTempFiles.cs
C# | Copy Code |
---|---|
string path = Path.GetTempFileName(); Assert.IsTrue(File.Exists(path)); File.WriteAllText(path, "Test"); TempFile filea = TempFile.Attach(path); Assert.AreEqual(path, filea.TempPath); Assert.AreEqual("Test", File.ReadAllText(filea.TempPath)); filea.Dispose(); Assert.IsFalse(File.Exists(path)); using (TempFile filec = new TempFile(path)) Assert.IsFalse(File.Exists(path)); |
VB.NET | Copy Code |
---|---|
Dim path As String = Path.GetTempFileName() Assert.IsTrue(File.Exists(path)) File.WriteAllText(path, "Test") Dim filea As TempFile = TempFile.Attach(path) Assert.AreEqual(path, filea.TempPath) Assert.AreEqual("Test", File.ReadAllText(filea.TempPath)) filea.Dispose() Assert.IsFalse(File.Exists(path)) Using filec As New TempFile(path) Assert.IsFalse(File.Exists(path)) End Using |
Target Platforms: Windows XP, Windows Server 2003, Windows Vista, Windows Server 2008, Windows 7
Reference
TempFile ClassTempFile Members
Used By
TestTransactionLog.TestBenchmarkWriteSpeed()ThreadedBTreeTest.TestAbortWritersAndRecover()
TestResXtoMcByProject.TestGenerateWin32Resource()
TestResXtoMcByProject.TestProjectResXVersionByAssembly()
TestResXtoMcByProject.TestCreateMessageAssembly()
TestResXtoMcByProject.TestProjectResXWithBadAssemblyInfo()
Boolean SecureTransfer.Client.Download(String,String)