本文整理汇总了C#中System.IO.DirectoryInfo.Empty方法的典型用法代码示例。如果您正苦于以下问题:C# DirectoryInfo.Empty方法的具体用法?C# DirectoryInfo.Empty怎么用?C# DirectoryInfo.Empty使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.IO.DirectoryInfo
的用法示例。
在下文中一共展示了DirectoryInfo.Empty方法的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: GlobalSetUp
//[SetUp]
public void GlobalSetUp()
{
if (_EnvironmentInitialised == false)
{
DirectoryInfo difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
if (difo.Exists)
{
difo.RemoveReadOnly();
difo.Empty(true);
}
difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
if (difo.Exists)
{
difo.RemoveReadOnly();
difo.Empty(true);
}
DirectoryInfo dif = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"));
dif.Copy(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
difo = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
difo.RemoveReadOnly();
_MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
CleanDirectories(_MFH);
_MFH = new MusicFolderHelper(Path.GetFullPath(@"..\..\TestFolders\OutFolder"));
_EnvironmentInitialised = true;
}
}
示例2: CleanDirectories
private void CleanDirectories(MusicFolderHelper imfh)
{
DirectoryInfo di = new DirectoryInfo(imfh.Cache);
di.RemoveReadOnly();
di.Empty(true);
GC.Collect();
GC.WaitForPendingFinalizers();
DirectoryInfo diroot = new DirectoryInfo(imfh.Root);
diroot.RemoveReadOnly();
diroot.Empty(true);
}
示例3: GUI
public GUI()
{
InitializeComponent();
if (!File.Exists("notify.wav") || !File.Exists("ringout.wav"))
{
MessageBox.Show("Make sure both notify.wav and ringout.wav exist in the application folder.");
Environment.Exit(1);
return;
}
sndGood = new SoundPlayer("notify.wav");
sndError = new SoundPlayer("ringout.wav");
try
{
Registry.SetValue(
@"HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
"D3BitGUI.exe", 9999);
Registry.SetValue(
@"HKEY_CURRENT_USER\SOFTWARE\Microsoft\Internet Explorer\MAIN\FeatureControl\FEATURE_BROWSER_EMULATION",
"D3BitGUI.exe", 9999);
}
catch { }
HookManager.KeyUp += OnKeyUp;
t = new Thread(CheckForUpdates);
t.Start();
Text += " " + version;
notifyIcon1.Text = "D3Bit " + version;
var di = new System.IO.DirectoryInfo("tmp");
if (!di.Exists)
{
di.Create();
}
else
{
di.Empty();
}
D3Bit.Data.LoadAffixes(Properties.Settings.Default.ScanLanguage);
}
示例4: CleanAndZip
public static void CleanAndZip(string userAppPath, string directoryToClear, string saveFile, string extractionPath)
{
if (!string.IsNullOrEmpty(directoryToClear))
{
var directoryInfo = new DirectoryInfo(directoryToClear);
// Let's clear it:
directoryInfo.Empty();
}
//Extract downloaded zip if it's a .zip file.
if (FileManager.GetExtension(saveFile) == "zip" && !string.IsNullOrEmpty(extractionPath))
{
Logger.Log("Unzipping file " + saveFile + " to " + extractionPath);
using (var zip = new ZipFile(saveFile))
{
zip.ExtractAll(extractionPath, true);
}
Logger.Log("Unzip complete");
}
}
示例5: MusicFolderHelper
internal MusicFolderHelper(string Root = null)
{
_Root = Path.GetFullPath( Path.Combine((Root ?? Environment.GetFolderPath(Environment.SpecialFolder.MyMusic)), "Music Collection"));
if (!Directory.Exists(_Root))
Directory.CreateDirectory(_Root);
_Temp = Path.Combine(Path.GetTempPath(),"Music Collection");
DirectoryInfo dire = new DirectoryInfo(_Temp);
if (!dire.Exists)
dire.Create();
else
dire.Empty();
_File = Path.Combine(_Root, "Files");
if (!Directory.Exists(_File))
Directory.CreateDirectory(_File);
_Cache = Path.Combine(_Root, "Cache");
if (!Directory.Exists(_Cache))
Directory.CreateDirectory(_Cache);
}
示例6: PrepareOutputDirectory
private static void PrepareOutputDirectory()
{
Directory.CreateDirectory(Config.WwwRootSkillsPath);
var outputDirectory = new DirectoryInfo(Config.WwwRootSkillsPath);
outputDirectory.Empty();
}
示例7: ExtractArchive
private void ExtractArchive()
{
DirectoryInfo extractTarget = new DirectoryInfo(this.ExtractDirectory);
if (extractTarget.Exists)
{
extractTarget.Empty();
}
else
{
extractTarget.Create();
}
string archive = ConfigurationManager.AppSettings["ArchiveName"];
archive = Path.Combine(this.DownloadDirectory, archive);
if (!string.IsNullOrWhiteSpace(archive))
{
System.IO.Compression.ZipFile.ExtractToDirectory(archive, this.ExtractDirectory);
}
}
示例8: CleanDestination
private void CleanDestination()
{
var directoryInfo = new DirectoryInfo(this.txtDestination.Text);
directoryInfo.Empty();
}
示例9: Test
public void Test()
{
string oout = Path.Combine(_SK.OutPath,"Custo test");
string pmcc = Path.Combine(oout, "Albums.mcc");
//Test Genre factory
using (IMusicSession ms = MusicSessionImpl.GetSession(_SK.Builder))
{
IMusicGenreFactory gf = ms.GetGenreFactory();
gf.Should().NotBeNull();
IGenre g = gf.CreateDummy();
g.Should().NotBeNull();
g.Name.Should().BeEmpty();
IGenre al = gf.Create("Rock");
al.Name.Should().Be("Rock");
al.Father.Should().BeNull();
al.FullName.Should().Be("Rock");
ms.AllGenres.Count.Should().Be(1);
IGenre al2 = gf.Create(@"Monde/Auvergne");
al2.Name.Should().Be("Auvergne");
al2.Father.Should().NotBeNull();
al2.Father.Name.Should().Be("Monde");
al2.FullName.Should().Be(@"Monde/Auvergne");
ms.AllGenres.Count.Should().Be(3);
IGenre al3 = gf.Create("Country");
al3.Name.Should().Be("Country");
al3.Father.Should().BeNull();
al3.FullName.Should().Be("Country");
ms.AllGenres.Count.Should().Be(4);
IGenre al4 = gf.Create(@"Country/Rap");
al4.Name.Should().Be("Rap");
al4.Father.Should().Be(al3);
al4.Father.Name.Should().Be("Country");
al4.FullName.Should().Be(@"Country/Rap");
ms.AllGenres.Count.Should().Be(5);
IGenre all4 = al3.AddSubGenre("Rap");
all4.Should().Be(al4);
IGenre al5 = al3.AddSubGenre("Rap/jjjj");
al5.Should().BeNull();
IGenre al6 = al3.AddSubGenre("Jazz");
al6.Should().NotBeNull();
al6.Name.Should().Be("Jazz");
}
using (IMusicSession ms = MusicSessionImpl.GetSession(_SK.Builder))
{
Assert.That(ms.AllAlbums.Count, Is.EqualTo(0));
Assert.That(ms.AllGenres.Count, Is.EqualTo(0));
Assert.That(ms.AllArtists.Count, Is.EqualTo(0));
IMusicImporter imi = ms.GetDBImporter();
Assert.That(imi, Is.Not.Null);
imi.Load();
Assert.That(ms.AllAlbums.Count, Is.EqualTo(0));
Assert.That(ms.AllGenres.Count, Is.EqualTo(25));
Assert.That(ms.AllArtists.Count, Is.EqualTo(0));
Console.WriteLine("Importing Music Folder");
IDirectoryImporterBuilder imib = ms.GetImporterBuilder(MusicImportType.Directory) as IDirectoryImporterBuilder;
Assert.That(imib, Is.Not.Null);
imib.Directory = DirectoryIn;
imib.DefaultAlbumMaturity = AlbumMaturity.Discover;
Assert.That(imib.IsValid, Is.True);
imi = imib.BuildImporter();
Assert.That(imi, Is.Not.Null);
imi.Load();
Assert.That(ms.AllAlbums.Count, Is.EqualTo(5));
Assert.That(ms.AllGenres.Count, Is.EqualTo(25));
Assert.That(ms.AllArtists.Count, Is.EqualTo(12));
AssertAlbums(ms, Albums[0], AlbumDescriptorCompareMode.AlbumMD);
Console.WriteLine("Import Successful 5 Albums");
IMusicExporterFactory imef = ms.GetExporterFactory();
Assert.That(imef, Is.Not.Null);
IMusicExporter ime = imef.FromType(MusicExportType.Custo);
Assert.That(ime, Is.Not.Null);
IMusicCompleteFileExporter imfe = ime as IMusicCompleteFileExporter;
Assert.That(imfe, Is.Not.Null);
//.........这里部分代码省略.........
示例10: Reinitialize
protected void Reinitialize()
{
CleanDirectories(false);
DirectoryInfo root = new DirectoryInfo(Root);
root.RemoveReadOnly();
root.Empty(true);
DirectoryInfo In = new DirectoryInfo(DirectoryIn);
In.RemoveReadOnly();
In.Empty(true);
string Pathentry = Path.Combine(Path.GetFullPath(@"..\..\TestFolders\InToBeCopied"), this.CopyName);
DirectoryInfo dif = new DirectoryInfo(Pathentry);
dif.Copy(DirectoryIn);
In = new DirectoryInfo(DirectoryIn);
In.RemoveReadOnly();
_SK = GetKeys();
CopyDBIfNeeded();
}
示例11: CleanDirectories
protected void CleanDirectories(bool tot = true)
{
DirectoryInfo di = new DirectoryInfo(Cache);
di.RemoveReadOnly();
di.Empty(true);
GC.Collect();
GC.WaitForPendingFinalizers();
if (tot)
{
DirectoryInfo diroot = new DirectoryInfo(Root);
diroot.RemoveReadOnly();
diroot.Empty(true);
//Directory.Delete(Root, true);
//while (diroot.Exists)
//{
// System.Threading.Thread.Sleep(200);
// di.Refresh();
//}
}
}
示例12: Run
public void Run()
{
Stream strmDiff = null;
DateTime dtStart = DateTime.Now;
int iFileCount = 0;
try
{
string strXmlInputRoot = ConfigurationManager.AppSettings.Get("XmlInputDirectory");
inputDirectory = new DirectoryInfo(string.Format("{0}\\today", strXmlInputRoot));
updateDirectory = new DirectoryInfo(string.Format("{0}\\update", strXmlInputRoot));
currentDirectory = new DirectoryInfo(string.Format("{0}\\current", strXmlInputRoot));
rejectDirectory = new DirectoryInfo(string.Format("{0}\\reject", strXmlInputRoot));
// delete all files in update directory
updateDirectory.Empty();
// get list of files in input & current directories
FileInfo[] arrFiles = inputDirectory.GetFiles();
arrFiles = (from oFile in arrFiles
orderby oFile.Length ascending
select oFile).ToArray<FileInfo>();
string[] arrCurrentFiles = Directory.GetFiles(currentDirectory.FullName);
writeLogInfo(string.Format("{0} files in today's folder", arrFiles.Length.ToString()));
int iMaxFiles = arrFiles.Length;
/*
if (iMaxFiles > 100)
iMaxFiles = 100;
*/
for (int i = 0; i < iMaxFiles; i++)
{
FileInfo fiFile = arrFiles[i];
iFileCount++;
writeLogInfo(fiFile.Name + " : " + iFileCount.ToString());
if (validateXml(fiFile))
{
xmlDocToday = oDoc;
if (!arrCurrentFiles.Contains<string>(string.Format("{0}\\{1}", currentDirectory.FullName, fiFile.Name)))
{
if (processWholeFile(fiFile, xmlDocToday))
{
// Move file to "Current" and "Update" folders
fiFile.CopyTo(string.Format("{0}\\{1}", updateDirectory.FullName, fiFile.Name));
fiFile.MoveTo(string.Format("{0}\\{1}", currentDirectory.FullName, fiFile.Name));
}
}
else
{
xmlCurrent.Load(string.Format("{0}\\{1}", currentDirectory.FullName, fiFile.Name));
strmDiff = new MemoryStream();
XmlTextWriter diffGram = new XmlTextWriter(new StreamWriter(strmDiff));
diffGram.Formatting = Formatting.Indented;
XmlDiff diff = new XmlDiff(XmlDiffOptions.IgnoreChildOrder);
diff.Compare(xmlCurrent, xmlDocToday, diffGram);
strmDiff.Position = 0;
strRead = new StreamReader(strmDiff);
string strDiffGraph = strRead.ReadToEnd();
xmlDiffGraph.LoadXml(strDiffGraph);
if (xmlDiffGraph.ChildNodes[1].HasChildNodes)
{
if (processWholeFile(fiFile, xmlDocToday))
{
// Move file to "Current" and "Update" folders
fiFile.CopyTo(string.Format("{0}\\{1}", updateDirectory.FullName, fiFile.Name));
fiFile.MoveTo(string.Format("{0}\\{1}", currentDirectory.FullName, fiFile.Name));
}
}
}
}
else
{
fiFile.MoveTo(string.Format("{0}\\{1}", rejectDirectory.FullName, fiFile.Name));
}
}
//PublishTours(itmTourFolder);
}
catch (Exception ex)
{
logError(ex.ToString());
}
finally
{
// clean up resources
if (strmDiff != null)
{
strmDiff.Close();
strmDiff.Dispose();
}
if (strRead != null)
{
strRead.Close();
strRead.Dispose();
}
writeLogInfo((DateTime.Now - dtStart).TotalSeconds.ToString());
}
}
示例13: CopyDirectory
/// <summary>
/// Copy the source directory into the destination directory.
/// </summary>
/// <param name="source">The directory containing the source files and folders.</param>
/// <param name="destination">The directory to copy the source into.</param>
private void CopyDirectory(string source, string destination)
{
Console.WriteLine("Emptying the directory [" + destination + "]");
var destinationInfo = new DirectoryInfo(destination);
destinationInfo.Empty();
var sourceInfo = new DirectoryInfo(source);
foreach (var fileInfo in sourceInfo.GetFiles())
{
fileInfo.CopyTo(Path.Combine(destination, fileInfo.Name));
}
foreach (var directoryInfo in sourceInfo.GetDirectories())
{
CopyDirectory(Path.Combine(source, directoryInfo.Name), Path.Combine(destination, directoryInfo.Name));
}
}
示例14: DeleteImage
public void DeleteImage(string imgName)
{
DirectoryInfo directory = new DirectoryInfo(Server.MapPath("/QrBarcode"));
directory.Empty(imgName);
}
示例15: teardown
public void teardown()
{
if (_EnvironmentInitialised)
{
DirectoryInfo dif = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder"));
dif.Empty(true);
}
}