private void timer1_Tick(object sender, EventArgs e) { if (bytTimerStep == 0) { bytTimerStep++; fnCloseTatip(); } else if (bytTimerStep == 1) { timer1.Interval = 15000; bytTimerStep++; //Launch TATIP text-to-speech software fnOpenTatip(); } else if (bytTimerStep == 2) { timer1.Interval = 2000; bytTimerStep++; //Upload News to the Telephony2 MDB fnCheckInForUpload(txtDtbShare.Text + strShareFtpDailynewsDirectory); } else if (bytTimerStep == 3) { timer1.Interval = 2000; bytTimerStep++; //Get & Convert All Unconverted text to Audio Name as label fnConvertAllAudioFiles(strSharePromptDirectory); //Get & Move all new books to the library fnMoveNewBookToLibrary(); } else if (bytTimerStep == 4) { btnCheckNow.Enabled = true; btnStart.Enabled = true; //Stop timer1 this.timer1.Enabled = false; //Check-In NEW DTB(s) from all share folders btnCheckNow_Click(sender, e); } else if (bytTimerStep == 6) { //Start Converting } else if (bytTimerStep == 240) { bytTimerStep++; if (b != null) { //b.fnDestroyConverter(); b = null; } if (a != null) { a.Abort(); a = null; } tmrHeartbeat.Enabled = false; tmrConverting.Enabled = false; tmrDelayStart.Enabled = false; button1.Enabled = false; button4.Enabled = false; fnCloseTatip(); } else if (bytTimerStep == 241) { timer1.Enabled = false; Application.Restart(); } else if (bytTimerStep == 250) { bytTimerStep++; if (b != null) { //b.fnDestroyConverter(); b = null; } if (a != null) { a.Abort(); a = null; } tmrHeartbeat.Enabled = false; tmrConverting.Enabled = false; tmrDelayStart.Enabled = false; button1.Enabled = false; button4.Enabled = false; fnCloseTatip(); } else if (bytTimerStep == 251) { timer1.Enabled = false; Application.Exit(); } }
private long GetDirectorySize(string strDirectoryPath) { try { // Get array of all file names. string[] a = Directory.GetFiles(strDirectoryPath, "*.*"); // Calculate total bytes of all files in a loop. long b = 0; foreach (string name in a) { // Use FileInfo to get length of each file. FileInfo info = new FileInfo(name); b += info.Length; } // Return total size return b; } catch (Exception) { return 1; //1 is not equal as 0 so the application will not stop at this time(this loop). } }