CSKernelFile.cFile.userSearchFile C# (CSharp) Method

userSearchFile() public method

public userSearchFile ( string &fullFileName, bool ifNotExistsIsOk, string description, bool saving, bool canOpenOther ) : bool
fullFileName string
ifNotExistsIsOk bool
description string
saving bool
canOpenOther bool
return bool
        public bool userSearchFile(ref string fullFileName,
                                   bool ifNotExistsIsOk,
                                   string description,
                                   bool saving,
                                   bool canOpenOther)
        {
            string userFile = "";
            bool extValid = false;
            bool nameValid = false;
            bool exists = false;

            do
            {

                if (showOpenFileDlg(out userFile,
                                    getFileExt(fullFileName),
                                    getFileName(fullFileName),
                                    getPath(fullFileName),
                                    description,
                                    saving))
                {

                    exists = fileExists(userFile);

                    if (exists || ifNotExistsIsOk)
                    {
                        if (fullFileName == " " || getFileWithoutExt(fullFileName) == "*")
                        {
                            nameValid = true;
                        }
                        else if (ifNotExistsIsOk
                                || canOpenOther
                                || getFileWithoutExt(fullFileName) == getFileWithoutExt(userFile))
                        {
                            nameValid = true;
                        }
                        if (nameValid)
                        {
                            if (fullFileName == " " || getFileExt(fullFileName) == "*")
                            {
                                extValid = true;
                            }
                            else if (ifNotExistsIsOk || getFileExt(fullFileName) == getFileExt(userFile))
                            {
                                extValid = true;
                            }
                            if (extValid && nameValid && (exists || ifNotExistsIsOk))
                            {
                                break;
                            }
                            else
                            {
                                nameValid = false;
                                extValid = false;
                            }
                        }

                    }
                }
                else
                {
                    return false;
                }

            } while (true);

            m_curPath = getPath(userFile);
            fullFileName = userFile;
            m_name = getFileName(userFile);
            m_path = getPath(userFile);

            return true;
        }