本文整理汇总了C#中TempDirectory.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# TempDirectory.Dispose方法的具体用法?C# TempDirectory.Dispose怎么用?C# TempDirectory.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类TempDirectory
的用法示例。
在下文中一共展示了TempDirectory.Dispose方法的7个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: TempDirectory_CallingDispose_DeletesDirectory
public void TempDirectory_CallingDispose_DeletesDirectory()
{
var tempDirectory = new TempDirectory();
var directory = tempDirectory.FullName;
tempDirectory.Dispose();
Assert.IsFalse(Directory.Exists(directory));
}
示例2: TempDirectory_CallingDispose_DeletesDirectoryContent
public void TempDirectory_CallingDispose_DeletesDirectoryContent()
{
var tempDirectory = new TempDirectory();
var filePath = Path.Combine(tempDirectory.FullName, "dummy.txt");
File.WriteAllText(filePath, "some random content");
tempDirectory.Dispose();
Assert.IsFalse(File.Exists(filePath));
}
示例3: TempDirectory_CallingDisposeWhenFilesLocked_DoesntFail
public void TempDirectory_CallingDisposeWhenFilesLocked_DoesntFail()
{
var tempDirectory = new TempDirectory();
var filePath = Path.Combine(tempDirectory.FullName, "dummy.txt");
File.WriteAllText(filePath, "some random content");
var stream = File.OpenRead(filePath);
tempDirectory.Dispose();
Assert.IsTrue(File.Exists(filePath));
stream.Close();
Directory.Delete(tempDirectory.FullName, true);
}
示例4: op_Dispose
public void op_Dispose()
{
TempDirectory directory = null;
DirectoryInfo info;
try
{
directory = new TempDirectory();
info = directory.Info;
}
finally
{
if (null != directory)
{
directory.Dispose();
}
}
Assert.Null(directory.Info);
info.Refresh();
Assert.False(info.Exists);
}
示例5: TestTempDirExists
public void TestTempDirExists()
{
TempDirectory dir = new TempDirectory();
Assert.IsTrue(dir.Exists);
dir.Dispose();
Assert.IsFalse(dir.Exists);
}
示例6: TestTempDirAlreadyDisposed
public void TestTempDirAlreadyDisposed()
{
TempDirectory dir = new TempDirectory();
dir.Dispose();
string path = dir.TempPath;
Assert.Fail(path);
}
示例7: TestCleanTempDirectoryWithOpenFile
public void TestCleanTempDirectoryWithOpenFile()
{
Stream io;
string path;
TempDirectory d = new TempDirectory();
Assert.IsTrue(Directory.Exists(path = d.TempPath));
io = File.Create(Path.Combine(path, "temp.txt"));
d.Dispose();
d = null;
Assert.IsTrue(Directory.Exists(path));
io.Dispose();
GC.Collect(0, GCCollectionMode.Forced);
GC.WaitForPendingFinalizers();
Assert.IsFalse(Directory.Exists(path));
}