public static void SendTorrentWithoutSavePath(string table, int index)
{
string filepath = null;
DataRow dr = null;
switch (table)
{
case "others":
try { dr = TorrentDataHandler.data.OthersTable.Rows.Find(index); }
catch { return; }
break;
case "movies":
try { dr = TorrentDataHandler.data.MoviesTable.Rows.Find(index); }
catch { return; }
break;
case "music":
try { dr = TorrentDataHandler.data.TorrentsTable.Rows.Find(index); }
catch { return; }
break;
default:
return;
}
try
{
Clipboard.SetData(DataFormats.StringFormat, dr["Save Structure"]);
if (dr != null)
dr.BeginEdit();
else
return;
filepath = (dr["File Path"].Equals(DBNull.Value)) ? null : (string)dr["File Path"];
//Preliminary error checking
if (filepath == null || !DirectoryHandler.GetFileExists(filepath))
{
dr.SetColumnError(TorrentDataHandler.data.TorrentsTable.Columns["File Path"], "File does not exist");
dr.EndEdit();
return;
}
if (!DirectoryHandler.GetFileExists(SettingsHandler.GetTorrentClientFolder() + "\\uTorrent.exe"))
{
ErrorWindow ew = new ErrorWindow();
ew.IssueGeneralWarning("Be sure uTorrent folder is correct", "uTorrent.exe does not exist", null);
dr.EndEdit();
return;
}
if ((bool)dr["Sent"])
{
dr.EndEdit();
return;
}
}
catch (Exception e)
{
if (dr != null)
dr.RowError = ("General exception: " + e.Message);
dr.EndEdit();
return;
}
try
{
Process sendTorrentProcess = new Process();
sendTorrentProcess.StartInfo.FileName = filepath;
sendTorrentProcess.Start();
sendTorrentProcess.Close();
/*
//torrentClient.exe /directory "C:\Save Path" "D:\Some folder\your.torrent"
string fullArgument = "/directory " + "\"" + filepath + "\"";
sendTorrentProcess.StartInfo.WorkingDirectory = SettingsHandler.GetTorrentClientFolder();
sendTorrentProcess.StartInfo.Arguments = fullArgument;
sendTorrentProcess.StartInfo.FileName = SettingsHandler.GetTorrentClient();
sendTorrentProcess.Start();
sendTorrentProcess.Dispose();
sendTorrentProcess.Close();
* */
dr["Sent"] = true;
if (dr.HasErrors)
dr.ClearErrors();
dr.EndEdit();
}
catch (Exception e)
{
if (dr != null)
dr.RowError = ("General exception: " + e.Message);
dr.EndEdit();
return;
}
}