public static void CheckMainFile() { if (File.Exists(txtFileName.Text)) { lnkFileName.Text = Path.GetFileName(txtFileName.Text); if (IoTools.FileOpened(txtFileName.Text)) { InvalidFile = true; lFileSize.Text = "File Size: Access Denied."; return; } lFileSize.Text = "File Size: " + IoTools.ParseFileSize(txtFileName.Text); lnkFileName.Enabled = true; InvalidFile = false; } else { InvalidFile = true; if (txtFileName.Text.Length > 0) { lnkFileName.Text = "File does not exists."; } else { lnkFileName.Text = "No files selected."; } lnkFileName.Enabled = false; lFileSize.Text = "File Size: N/A"; } UpdatePartsInfo(); }
public static bool CheckSplitter(FrmBase frm) { //Check if the file existed if (!File.Exists(txtFileName.Text)) { string msg = "Invalid source file."; if (txtFileName.Text.Length > 0) { msg = "The file :" + "\n\'" + txtFileName.Text + "\' " + "does not exists."; } frm.ShowMessage(msg, MsgType.Error); return(false); } else { if (IoTools.FileOpened(txtFileName.Text)) { frm.ShowMessage("Source file Access Denied, file is being used by another process.", MsgType.Error); return(false); } } if (GetPartSize() <= 0) { frm.ShowMessage("Invalid part size.", MsgType.Error); return(false); } if (!Directory.Exists(txtFolderName.Text)) { string msg = "Invalid destination folder name."; if (txtFolderName.Text.Length > 0) { msg = "Destination folder:" + "\n\'" + txtFolderName.Text + "\' " + "does not exists."; } frm.ShowMessage(msg, MsgType.Error); return(false); } return(true); }
public static bool LoadParts(FrmBase frm) { string fileName = GetFirstPart(); if (fileName == null) { frm.ShowMessage("Invalid source file name, Can not find first part.", MsgType.Error); return(false); } string pDir = Directory.GetParent(txtFileName.Text).FullName; OutFileName = Path.Combine(pDir, fileName); string fName = fileName + ".1.qsx"; //First part string fPath = Path.Combine(pDir, fName); partSize = IoTools.GetFileSize(fPath); if (partSize == 0) { frm.ShowMessage("File Access Denied, file is being used by another process.", MsgType.Error); return(false); } Header hdr = new Header(); if (!File.Exists(fPath)) { frm.ShowMessage("Source file: '" + fPath + "' does not exists.", MsgType.Error); return(false); } if (IoTools.FileOpened(fPath)) { frm.ShowMessage("File Access Denied, file is being used by another process.", MsgType.Error); return(false); } if (hdr.ReadHeader(fPath)) { int pNum = int.Parse(hdr.HeaderBlock.Rows[0]); //Parts number string[] files = new string[pNum]; for (int i = 0; i < pNum; i++) { string cFile = Path.Combine(pDir, hdr.HeaderBlock.Rows[i + 1]); if (File.Exists(cFile)) { files[i] = cFile; } else { //File 'cFile' Does not exists frm.ShowMessage("Source file: '" + cFile + "' is missing.", MsgType.Error); return(false); } } Joiner.FileNames = files; if (hdr.HeaderBlock.Rows.Count > pNum + 1) { Joiner.OutputSize = long.Parse(hdr.HeaderBlock.Rows[pNum + 1]); } } else { frm.ShowMessage("'" + fPath + "' is not a valid source file.", MsgType.Error); return(false); } return(true); }