private void createLogFile() { if (!System.IO.File.Exists(errorLog)) { Gtools.createFile(errorLog, DateTime.Now.ToString() + Environment.NewLine + "Error Log file Created\n" + Environment.NewLine); } }
private void btnCreateBatch_Click(object sender, EventArgs e) { string fileListName = Gtools.getTimeStamp() + "_" + UserList[cbUser.SelectedIndex].userName + "_" + txtBackUpName.Text + ".json"; string fileListPath = Path.Combine(savePath, fileListName); saveFileLIst(fileListPath); string param1 = fileListPath; // filelist.json Path parameter string param2 = (chbUploadMultiple.Checked)? txtBackUpName.Text : txtFileName.Text; // file Name parameter string param3 = (txtParentID.Text != string.Empty) ? txtParentID.Text : "0"; // Parent Id parameter int param4 = cbUser.SelectedIndex; // user index parameter int param5 = (MessageBox.Show("Do you want to Upload only \"new/changed\" files to Google Drive?" + UserList[cbUser.SelectedIndex].userName, "Uploading Arguments", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == DialogResult.Yes) ? 1 : 0; // Copy Only new parameter int param6 = (chbCompress.Checked) ? 1 : 0; // comporess parameter string appPath = "\"" + Path.GetFullPath(Application.ExecutablePath) + "\""; string contentToWrite = "cls" + Environment.NewLine + "@ECHO OFF" + Environment.NewLine + "set param1=\"" + param1 + "\"" + Environment.NewLine + "set param2=\"" + param2 + "\"" + Environment.NewLine + "set param3=\"" + param3 + "\"" + Environment.NewLine + "set param4=\"" + param4 + "\"" + Environment.NewLine + "set param5=\"" + param5 + "\"" + Environment.NewLine + "set param6=\"" + param6 + "\"" + Environment.NewLine + appPath + " %param1% %param2% %param3% %param4% %param5% %param6%"; FolderBrowserDialog fbd = new FolderBrowserDialog(); DialogResult result = fbd.ShowDialog(); switch (result) { case DialogResult.OK: Gtools.createFile(Path.Combine(fbd.SelectedPath, UserList[cbUser.SelectedIndex].userName + "_File_" + txtFileName.Text.Split('.').First() + ".bat") , contentToWrite); break; default: break; } }
private void loadUsers(string savePath, string saveFile) { Directory.CreateDirectory(savePath); try { if (System.IO.File.Exists(saveFile)) { UserList.Clear(); UserList = JsonConvert.DeserializeObject <List <User> >(System.IO.File.ReadAllText(saveFile)); } else { Gtools.createFile(saveFile, "[ ]"); loadUsers(savePath, saveFile); } } catch (Exception exc) { System.Diagnostics.Debug.WriteLine(exc.Message + " Load User Error.\n"); Gtools.writeToFile(frmMain.errorLog, Environment.NewLine + DateTime.Now.ToString() + Environment.NewLine + exc.Message + " Load User Error.\n"); } }