Ejemplo n.º 1
0
        public static bool CheckJoiner(FrmBase frm)
        {
            //Check if the file existed
            if (!File.Exists(txtFileName.Text))
            {
                string msg = "Invalid source file.";
                if (txtFileName.Text.Length > 0)
                {
                    msg = "The source file :" + "\n\'" + txtFileName.Text + "\' " + "does not exists.";
                }

                frm.ShowMessage(msg, 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);
        }
Ejemplo n.º 2
0
        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);
        }
Ejemplo n.º 3
0
        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);
        }