public void FilterdCopyTest() { string src = Path.Combine(_TestPath, "CopySrc"); if (Directory.Exists(src)) { Directory.Delete(src, true); } Directory.CreateDirectory(src); const string subFolder = "CopySubFolder"; string subFolderPath = Path.Combine(src, subFolder); Directory.CreateDirectory(subFolderPath); const string name = "T1.xhtml"; string srcName = Path.Combine(src, name); File.Copy(Path.Combine(_TestPath, name), srcName); File.SetAttributes(srcName, File.GetAttributes(srcName) & ~FileAttributes.ReadOnly); string subFilePath = Path.Combine(subFolderPath, name); File.Copy(Path.Combine(_TestPath, name), subFilePath); File.SetAttributes(subFilePath, File.GetAttributes(subFilePath) & ~FileAttributes.ReadOnly); string dst = Path.Combine(_TestPath, "CopyDst"); if (Directory.Exists(dst)) { Directory.Delete(dst); } MyFolders.Copy(src, dst, subFolder); Assert.AreEqual(false, Directory.Exists(Path.Combine(dst, subFolder)), "Folder exists when it should have been filtered"); Directory.Delete(src, true); Directory.Delete(dst, true); }
public static string GetFolder(NiceSystemInfo systemInfo, MyFolders f) { string strSystem = systemInfo.Default ? "" : "_SubSystem_" + systemInfo.Name + "\\"; string strRoot = GetMachineRoot() + "_NiceSolution\\ASP_Zap\\" + strSystem; switch (f) { case MyFolders.ASP_QueuedMessages_: return(strRoot + "Queue"); case MyFolders.ASP_ProcessedMessages_: return(strRoot + "Processed"); case MyFolders.ASP_DisposedMessages_: return(strRoot + "Disposed"); case MyFolders.ASP_UserAccountFolder_: return(strRoot + "Users"); case MyFolders.ASP_UserWalletFolder_: return(strRoot + "Wallets"); case MyFolders.ASP_ServerStateFolder: return(strRoot + "ServerState"); } return(null); }
public void CreateDirectoryTest() { const string name = "Dictionary1"; string directory = Path.Combine(_TestPath, name); MyFolders.CreateDirectory(directory); Assert.AreEqual(true, Directory.Exists(directory), "Folder does not exists"); Directory.Delete(directory); }
public static void WriteToFile(this MyFolders folder, NiceSystemInfo systemInfo, IData_Base data, IMyLog log) { string file = FolderNames.GetFolder(systemInfo, folder) + Path.DirectorySeparatorChar + data.GetFileName(); using (BinaryWriter bw = new BinaryWriter(OpenFile.ForWrite(file, log))) { data.NetTo(bw); } }
public void GetNewNameTest() { string directory = _TestPath; string name = "Dictionary1"; string expected = "Dictionary1"; string actual; actual = MyFolders.GetNewName(directory, name); Assert.AreEqual(expected, actual); }
private void SelectFolderButton1_Click(object sender, RoutedEventArgs e) { var ookiiDialog = new VistaFolderBrowserDialog(); if (ookiiDialog.ShowDialog() == true) { //MessageBox.Show(ookiiDialog.SelectedPath); MyFolders.Add(ookiiDialog.SelectedPath); } }
private void ScanButton_Click(object sender, RoutedEventArgs e) { List <string> searchPath = new List <string>(); Debug.Print("ScanButton was clicked."); if (MyFolders.Count() > 0) { searchPath = GetUniquePaths(); ScanFolders(searchPath); } }
public void GetNewNameT2Test() { string directory = _TestPath; string name = "Dictionary1"; string existingDirectory = Path.Combine(directory, name); Directory.CreateDirectory(existingDirectory); string expected = "Dictionary2"; string actual; actual = MyFolders.GetNewName(directory, name); Assert.AreEqual(expected, actual); Directory.Delete(existingDirectory); }
public void CopyTest() { string src = Path.Combine(_TestPath, "CopySrc"); Directory.CreateDirectory(src); const string name = "T1.xhtml"; string srcName = Path.Combine(src, name); File.Copy(Path.Combine(_TestPath, name), srcName); File.SetAttributes(srcName, File.GetAttributes(srcName) & ~FileAttributes.ReadOnly); string dst = Path.Combine(_TestPath, "CopyDst"); MyFolders.Copy(src, dst, ""); Assert.AreEqual(true, File.Exists(Path.Combine(dst, name))); Directory.Delete(src, true); Directory.Delete(dst, true); }
private List <string> GetUniquePaths() { Debug.WriteLine("GetUniquePaths():"); List <string> tempList = new List <string>(); //List<string> searchList = new List<string>(); var sortedList = MyFolders.OrderBy(x => x.Length).Distinct().ToList(); //searchList = sortedList.ToList(); if (sortedList.Count() == 1) { Debug.Print(sortedList[0]); return(sortedList); } else { for (int i = 0; i < sortedList.Count() - 1; i++) { for (int j = i + 1; j < sortedList.Count; j++) { Debug.Print("---"); Debug.WriteLine(sortedList[i]); Debug.WriteLine(sortedList[j]); if (sortedList[j].Contains(sortedList[i])) { tempList.Add(sortedList[j]); Debug.Print(":"); Debug.Print(string.Join("\n", tempList)); Debug.Print(":"); } } } Debug.Print("=== tempList ==="); foreach (var item in tempList) { Debug.Print(item); sortedList.Remove(item); } Debug.Print("=== sortedList ==="); Debug.Print(string.Join("\n", sortedList)); return(sortedList); } }
private static void createFolders(NiceSystemInfo systemInfo, string preText) { int i = 0; while (true) { MyFolders f = (MyFolders)i; if (f == MyFolders._end) { break; } string s = f.ToString(); if (s.StartsWith(preText)) { Create1Folder(GetFolder(systemInfo, f)); } i++; } }
private void DeleteFolder_Click(object sender, RoutedEventArgs e) { if (FolderListbox.SelectedItems != null) { Debug.WriteLine("SelectedItems is NOT null!"); var selectedFiles = FolderListbox.SelectedItems.Cast <string>().ToList(); foreach (var item in selectedFiles) { //printCollection(MyFolders); MyFolders.Remove(item); //Debug.WriteLine(item); PrintCollection(MyFolders); } } else { Debug.WriteLine("SelectedItems is null!"); } }
private void DeleteAllFolder_Click(object sender, RoutedEventArgs e) { MyFolders.Clear(); }
private void forEach(NiceSystemInfo niceSystem, DateTime newerThan, string containsUser, MyFolders folder, IMyLog log, dProcess_Data_Net__00NormalMessage cb) { foreach (var f1 in Directory.GetFiles(FolderNames.GetFolder(niceSystem, folder))) { if ((containsUser != null) && (!f1.Contains(containsUser))) { // wrong user continue; } DateTime fileTime = ASPTrayBase.s_MsgFile_GetDateTimeOfMessageFile(f1); if (fileTime >= newerThan) { if (!ASPTrayBase.s_MsgFile_IsOld(f1)) { ASPTrayBase d1 = ASPTrayBase.ReadOne(f1, log); if ((d1 != null) && (d1.GetEnumType() == ASPTrayBase.eASPtrayType.NormalMessage)) { cb((Data_Net__00NormalMessage)d1); } } } } }