Пример #1
0
    //  - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - - -
    //  Получить имя файла с помощью текстового меню
    public static string   SelectFileName(string FileMask)
    {
        if (FileMask == null)
        {
            return("");
        }
        if (FileMask.Trim().Length == 0)
        {
            return("");
        }
        string[] FileList;
        FileList = CCommon.GetFileList(FileMask);
        if (FileList == null)
        {
            return("");
        }
        if (FileList.Length == 0)
        {
            return("");
        }
        int FileCount = 0;

        foreach (string FileName in FileList)
        {
            if (FileName != null)
            {
                if (FileName.Trim() != "")
                {
                    if (CCommon.GetFileName(FileName).IndexOf("_") < 0)
                    {
                        FileCount++;
                    }
                }
            }
        }
        if (FileCount < 1)
        {
            return("");
        }
        string[] FileNames = new   string[FileCount];
        int      I         = 0;

        foreach (string FileName in FileList)
        {
            if (FileName != null)
            {
                if (FileName.Trim() != "")
                {
                    if ((CCommon.GetFileName(FileName).IndexOf("_") < 0) && (I < FileCount))
                    {
                        FileNames[I++] = FileName;
                    }
                }
            }
        }
        string[] MenuItems = new   string[FileCount];
        for (I = 0; I < FileCount; I++)
        {
            MenuItems[I] = CCommon.GetFileName(FileNames[I]);
            long FileSize = CCommon.GetFileSize(FileNames[I]);
            if (FileSize < 892)
            {
                FileSize = 0;
            }
            else
            {
                FileSize = (FileSize - 298) / 594;
            }
            MenuItems[I] = CCommon.Left(CCommon.GetFileName(FileNames[I]), 16) + " " + CCommon.Right(FileSize.ToString(), 5) + " строк";
        }
        I = CConsole.GetMenuChoice(MenuItems);
        if (I > 0)
        {
            return(FileNames[I - 1]);
        }
        return("");
    }