当前位置: 首页>>代码示例>>C#>>正文


C# TempDirectory.Dispose方法代码示例

本文整理汇总了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));
        }
开发者ID:cristiingineru,项目名称:ExpressionViewer,代码行数:9,代码来源:TempDirectoryTests.cs

示例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));
        }
开发者ID:cristiingineru,项目名称:ExpressionViewer,代码行数:10,代码来源:TempDirectoryTests.cs

示例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);
        }
开发者ID:cristiingineru,项目名称:ExpressionViewer,代码行数:14,代码来源:TempDirectoryTests.cs

示例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);
        }
开发者ID:KarlDirck,项目名称:cavity,代码行数:22,代码来源:TempDirectory.Facts.cs

示例5: TestTempDirExists

		public void TestTempDirExists()
		{
			TempDirectory dir = new TempDirectory();
			Assert.IsTrue(dir.Exists);
			dir.Dispose();
			Assert.IsFalse(dir.Exists);
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:7,代码来源:TestTempFiles.cs

示例6: TestTempDirAlreadyDisposed

		public void TestTempDirAlreadyDisposed()
		{
			TempDirectory dir = new TempDirectory();
			dir.Dispose();
			string path = dir.TempPath;
			Assert.Fail(path);
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:7,代码来源:TestTempFiles.cs

示例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));
		}
开发者ID:hivie7510,项目名称:csharptest-net,代码行数:17,代码来源:TestTempFiles.cs


注:本文中的TempDirectory.Dispose方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。