public void CreateDeleteDirectoryFileExists() { var dfs = new GenLib.Services.DirectoryFile(); const string testFilename = "C:\\DirectoryFileServicesTest\\testFilename.txt"; dfs.DeleteFileAndDirectory(testFilename); Assert.False(dfs.FileExists(testFilename)); dfs.CreateDirectory(testFilename); var fs = File.Create(testFilename); Assert.True(dfs.FileExists(testFilename)); // must dispose of file handle otherwise delete will fail fs.Dispose(); dfs.DeleteFileAndDirectory(testFilename); Assert.False(dfs.FileExists(testFilename)); Assert.True(true); }
public void DeleteDirectoryWithFiles() { var dfs = new GenLib.Services.DirectoryFile(); const string testDirectory = "C:\\DirectoryFileServicesTest\\"; const string testFilename = "testFilename.txt"; const string fullPathFilename = testDirectory + testFilename; dfs.DeleteDirectoryWithFiles(testDirectory); Assert.False(Directory.Exists(testDirectory)); dfs.CreateDirectory(testDirectory); var fs = File.Create(fullPathFilename); fs.Dispose(); Assert.True(dfs.FileExists(fullPathFilename)); dfs.DeleteDirectoryWithFiles(testDirectory); Assert.False(Directory.Exists(testDirectory)); Assert.True(true); }