Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7921819
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T16:43:39+00:00 2026-06-03T16:43:39+00:00

I am trying to find a certain string in a text file, then create

  • 0

I am trying to find a certain string in a text file, then create a folder based off of what that string says, somewhere along the lines, what I have just stops, it doesn’t exception, it doesn’t spit out errors, it just stops.

the strings I am trying to find are set up like this:

50.1 : Oxygas ------> = 1
50.2 : laser -------> = 0 
etc. 

foreach (string file in files)
        {
            string thepathoflife = Path.GetFullPath(file);
            //CreatetheFolder(file)
            string filetocopy = file;
            object bob = file.Clone();
            string bobby = bob.ToString();
            string location = file;
            bool b = false;
            string extension = Path.GetExtension(file);
            string thenameofdoom = Path.GetFileNameWithoutExtension(file);
            string filename = Path.GetFileName(file);
            ////bobby.Move(@"\\TEST12CVG\Public\Posts\Temporaryjunk" + filename);
            // string oldlocation = filename+extension;

            if (extension == ".pst" ||
              extension == ".tec" ||
              extension == ".pas" ||
              extension == ".snc" ||
              extension == ".cst" ||
              extension == ".xml")
            {
                b = true;
            }

            if (thenameofdoom == "Plasma" ||
              thenameofdoom == "Oxygas" ||
              thenameofdoom == "plasma" ||
              thenameofdoom == "oxygas" ||
              thenameofdoom == "Oxyfuel" ||
              thenameofdoom == "oxyfuel")
            {
                b = false;
            }


            if (b == true)
            // System.IO.File.WriteAllText(newlocation, bobby);
            {
                bool plasma = false;
                bool oxygas = false;
                bool punch = false;
                bool laser = false;
                var findLevel = 6;
                var path = @thepathoflife;
                var levels = path.Split(Path.DirectorySeparatorChar);
                var second = levels.Length > findLevel ? levels[findLevel] : null; 



     //this is where the problem starts.
 StreamReader s = new StreamReader(@thepathoflife);

                StreamReader st = new StreamReader(@thepathoflife);
                string currentLine;
                string searchString = "50.2 :";
                bool foundText = false;
                string searchStringab = "= 1";
                bool foundTextab = false;

                do
                {
                    currentLine = st.ReadLine();
                    if (currentLine != null)
                    {
                        foundText = currentLine.Contains(searchString);
                        foundTextab = currentLine.Contains(searchStringab);
                    }
                }
                while (currentLine != null && !foundText || currentLine != null && !foundTextab);

                if (foundText||foundTextab)
                {
                    plasma = true; //do something
                }
  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-03T16:43:41+00:00Added an answer on June 3, 2026 at 4:43 pm

    You opened two StreamReader on same file without closing first one:

    StreamReader s = new StreamReader(@thepathoflife);
    StreamReader st = new StreamReader(@thepathoflife);
    

    and finally you didn’t dispose any of them, use using to prevent such a mistakes:

    using(StreamReader st = new StreamReader(@thepathoflife))
    {
     do stuff;
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to find some items that contain a certain string. If I do:
I'm trying to find out if a string contains certain SQL commands that alter
I am trying to find all the digits following a certain String pattern using
I have a list of keywords I'm trying to find in a text string.
I am trying to find a list of relevant types to a certain string
I'm trying to create a program that will return a certain number decomposed to
I'm trying to replace the occurence of a certain String from a given text
Im looking for a function that will enable me to find a certain string
I'm trying to find certain keywords in a string with python. The string is
I'm trying to find a solution to highlight part of a text file in

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.