//[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; } }
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); }
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); }
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"); } }
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); }
private static void PrepareOutputDirectory() { Directory.CreateDirectory(Config.WwwRootSkillsPath); var outputDirectory = new DirectoryInfo(Config.WwwRootSkillsPath); outputDirectory.Empty(); }
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); } }
private void CleanDestination() { var directoryInfo = new DirectoryInfo(this.txtDestination.Text); directoryInfo.Empty(); }
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); imfe.AlbumToExport = ms.AllAlbums; Directory.CreateDirectory(oout); imfe.FileDirectory = oout; imfe.Export(); Assert.That(File.Exists(pmcc), Is.True); DirectoryInfo fi = new DirectoryInfo(DirectoryIn); fi.Empty(true); Assert.That(fi.GetFiles().Length, Is.EqualTo(0)); IMusicRemover imr = ms.GetMusicRemover(); Assert.That(imr, Is.Not.Null); imr.AlbumtoRemove.AddCollection(ms.AllAlbums); imr.IncludePhysicalRemove = true; imr.Comit(); Assert.That(ms.AllAlbums.Count, Is.EqualTo(0)); } 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)); _SK.Settings.RarFileManagement.RarZipFileAfterSuccessfullExtract = CompleteFileBehaviour.Delete; IMusicImporterBuilder imib = ms.GetImporterBuilder(MusicImportType.Custo); Assert.That(imib, Is.Not.Null); ICustoFilesImporterBuilder icf = imib as ICustoFilesImporterBuilder; Assert.That(icf, Is.Not.Null); icf.Files = new string[] { pmcc }; icf.DefaultAlbumMaturity = AlbumMaturity.Discover; Assert.That(icf.IsValid, Is.True); IMusicImporter imit = icf.BuildImporter(); Assert.That(imit, Is.Not.Null); imit.Load(); AssertAlbums(ms, Albums[0], AlbumDescriptorCompareMode.AlbumMD); Assert.That(File.Exists(pmcc), Is.False); } 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(); AssertAlbums(ms, Albums[0], AlbumDescriptorCompareMode.AlbumMD); //TestAlbums(ms.AllAlbums); } }
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(); }
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(); //} } }
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()); } }
/// <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)); } }
public void DeleteImage(string imgName) { DirectoryInfo directory = new DirectoryInfo(Server.MapPath("/QrBarcode")); directory.Empty(imgName); }
public void teardown() { if (_EnvironmentInitialised) { DirectoryInfo dif = new DirectoryInfo(Path.GetFullPath(@"..\..\TestFolders\InFolder")); dif.Empty(true); } }
public void Initialize(string name, XmlElement xmlConfig) { // Read these from Domain XML file _name = name; _populationSize = XmlUtils.GetValueAsInt(xmlConfig, "PopulationSize"); _specieCount = XmlUtils.GetValueAsInt(xmlConfig, "SpecieCount"); _activationSchemeCppn = ExperimentUtils.CreateActivationScheme(xmlConfig, "ActivationCppn"); _activationScheme = ExperimentUtils.CreateActivationScheme(xmlConfig, "Activation"); _complexityRegulationStr = XmlUtils.TryGetValueAsString(xmlConfig, "ComplexityRegulationStrategy"); _complexityThreshold = XmlUtils.TryGetValueAsInt(xmlConfig, "ComplexityThreshold"); _description = XmlUtils.TryGetValueAsString(xmlConfig, "Description"); _parallelOptions = ExperimentUtils.ReadParallelOptions(xmlConfig); _parallelOptions.MaxDegreeOfParallelism = Environment.ProcessorCount / 2; _visualFieldResolution = XmlUtils.GetValueAsInt(xmlConfig, "Resolution"); _visualFieldPixelCount = _visualFieldResolution * _visualFieldResolution; _lengthCppnInput = XmlUtils.GetValueAsBool(xmlConfig, "LengthCppnInput"); _eaParams = new NeatEvolutionAlgorithmParameters(); _eaParams.SpecieCount = _specieCount; // Set these manually, use a high mutator just to test the water _neatGenomeParams = new NeatGenomeParameters() { AddConnectionMutationProbability = 0.10, DeleteConnectionMutationProbability = 0.10, ConnectionWeightMutationProbability = 0.90, AddNodeMutationProbability = 0.05, InitialInterconnectionsProportion = 0.10 }; // Clear OUTPUT and FITNESS directories before starting var directory = new DirectoryInfo(Constants.OUTPUT_DIR); directory.Empty(); directory = new DirectoryInfo(Constants.FITNESS_DIR); directory.Empty(); directory = new DirectoryInfo(Constants.PLOTS_DIR); directory.Empty(); }