示例#1
0
        public string chuli(string txtname)
        {
            string title = Path.GetFileNameWithoutExtension(txtname);

            if (radioButton1.Checked == true)
            {
                return(title);
            }
            if (radioButton2.Checked == true)
            {
                string[] text = title.Split(new string[] { textBox2.Text.Trim() }, StringSplitOptions.None);
                return(text[0]);
            }
            if (radioButton3.Checked == true)
            {
                if (textBox3.Text == "")
                {
                    textBox4.Text = "路径为空";
                    return(title);
                }
                ArrayList lists = new ArrayList();


                string[] FileRead = ReadTxt.Split(new string[] { "\r\n" }, StringSplitOptions.None);
                foreach (String ReadLine in FileRead)
                {
                    if (title.Contains(ReadLine.Trim()))
                    {
                        lists.Add(ReadLine.Trim());
                    }
                }
                Random rd = new Random();


                if (lists.Count > 0)
                {
                    int value = rd.Next(0, lists.Count);

                    return(lists[value].ToString());
                }
                else
                {
                    return(title);
                }
            }
            else
            {
                return(title);
            }
        }