Beispiel #1
0
        private void cMainForm_FormClosing(object sender, FormClosingEventArgs e)
        {
            TorrentHandler handler = new TorrentHandler();

            //handler.WriteActiveTorrents(activeTorrents);

            for (int i = 0; i < downloadList.Count; i++) //Save resume data for all torrents that aren't finished.
            {
                if (!downloadList[i].handle.IsFinished)
                {
                    downloadList[i].SaveResumeData();
                }
            }

            Environment.Exit(Environment.ExitCode);
        }
Beispiel #2
0
        readonly string activeTorrentsPath = string.Concat($@"C:\Users\", Environment.UserName, @"\AppData\Local\Bitloader\active_torrents.tor"); // Environment.UserName
        public cMainForm()
        {
            if (mainForm != null)
            {
                throw new Exception("Only one instance of cMainForm may ever exist!");
            }

            mainForm = this;

            if (session != null)
            {
                throw new Exception("Only one instance of session may ever exist!");
            }

            session = new Session();

            InitializeComponent();
            string settingsFolder = @"C:\Users\" + Environment.UserName + @"\AppData\Local\Bitloader"; //Use Environment.UserName Here for releases

            if (!Directory.Exists(settingsFolder))
            {
                Directory.CreateDirectory(settingsFolder);
            }

            this.Show();
            SettingsForm settings = new SettingsForm();

            Thread.Sleep(100);
            settings.Close();

            TorrentHandler handler = new TorrentHandler();

            if (File.Exists(activeTorrentsPath))
            {
                handler.ReadActiveTorrents();
            }
        }