private void move_special(String fileName, String extension, Folders folders) { SpecialFile sf = new SpecialFile(DefaultPath + "\\" + fileName); for (int i = folders.items.Count - 1; i > (-1); i--) { Folder_Item d = folders.items[i]; if (d.ownsExtension(extension)) { String belongings = sf.getBelongingsFolder(); Console.WriteLine("Dir Name " + belongings); if (belongings != null) { IO.getInstance().moveDir(DefaultPath, DefaultPath + "\\" + d.Folder, belongings); } Speaker.getInstance().speak("Moved" + fileName + " to " + d.Folder); IO.getInstance().move(DefaultPath, DefaultPath + "\\" + d.Folder, fileName); break; } } }
public void move_to_right_folder(String fileName, String extension, Folders folders) { if (extension.Equals(".html") || extension.Equals(".htm")) { move_special(fileName, extension, folders); } else { Boolean moved = false; for (int i = folders.items.Count - 1; i > (-1); i--) { Folder_Item d = folders.items[i]; if (d.ownsExtension(extension)) { Speaker.getInstance().speak("Moved" + fileName + " to " + d.Folder); try { IO.getInstance().move(DefaultPath, DefaultPath + "\\" + d.Folder, fileName); moved = true; break; } catch (Exception es) { moved = true; } } } if (!moved) { Folder_Item Item = folders.items.Single(d => d.Folder.Equals("Others")); IO.getInstance().move(DefaultPath, DefaultPath + "\\" + Item.Folder, fileName); } } }