Home > Enterprise >  Text Filter with text*text
Text Filter with text*text

Time:12-13

i want text file from game filter (Example:)

1 - "coolboy954.easy", "coolboy77.easy", "coolboy5.easy" | but now "‹: coolboy77.easy h½…:;L:ò>" or "‹:»h¢½x coolboy954.easy ½_>?«ªÊ@ô"

want this filter output: coolboy954.easy coolboy77.easy coolboy5.easy

Example Like (Filter only = coolboy*.easy)

want in c# or any other method filter text files

CodePudding user response:

using linq

var yourListStrings = new List<string> { "coolboy954.easy", 
"coolboy77.easy","coolboy5.easy" , "test text" };

    var data = yourListStrings.Where(s => s.Contains("coolboy")).ToList();

    foreach(var i in data){
        Console.WriteLine(i);
    }

CodePudding user response:

    [STAThread]
static void Main()
{
    AllocConsole();

    Stream myStream = null;
    List<string> gameTextfiles = new List<string>();
    var data = gameTextfiles.Where(s => s.Contains("FO_")).ToList();

    OpenFileDialog theDialog = new OpenFileDialog();
    theDialog.Title = "Open csa File";
    theDialog.Filter = "CSA files|*.csa";
    theDialog.InitialDirectory = @"C:\";
    if (theDialog.ShowDialog() == DialogResult.OK)
    {
        try
        {
            if ((myStream = theDialog.OpenFile()) != null)
            {
                using (myStream)
                {
                    gameTextfiles.Add("idk");

                    using (StreamWriter writer = new StreamWriter("getstring.txt"))
                    {
                        foreach (var i in data)
                        {
                            Console.WriteLine(i);
                            writer.WriteLine(i);
                        }
                    }
                }
            }
        }
        catch (Exception ex)
        {
            MessageBox.Show(ex.Message);
        }
    }
}

want add on openfiledialog and read text and filter this to new file (write)

  • Related