public static string MoveTorrentFile(Torrent t) { FileInfo fi; DirectoryInfo cslSaveFolder = null; string filename; string file = t.GetPath(); string where = (t.GetDiscard()) ? "unhandled" : "handled"; try { fi = new FileInfo(file); filename = fi.Name; switch (where) { case "handled": cslSaveFolder = new DirectoryInfo(SettingsHandler.GetTorrentSaveFolder() + @"\[CSL] -- Handled Torrents\"); break; case "unhandled": cslSaveFolder = new DirectoryInfo(SettingsHandler.GetTorrentSaveFolder() + @"\[CSL] -- Unhandled Torrents\"); break; default: cslSaveFolder = new DirectoryInfo(SettingsHandler.GetTorrentSaveFolder() + '\\' + where + '\\'); break; } if (!cslSaveFolder.Exists) cslSaveFolder.Create(); if (fi.FullName.Equals(cslSaveFolder + fi.Name)) //In handled directory already return fi.FullName; if (File.Exists(cslSaveFolder.FullName + fi.Name)) { fi.Delete(); return cslSaveFolder.FullName + fi.Name; } else if (fi != null) { fi.MoveTo(cslSaveFolder.FullName + "\\" + fi.Name); return fi.FullName; } else { return null; } } catch (Exception e) { LogError(e.Message + "\n" + e.StackTrace); return null; } }