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

  • Home
  • SEARCH
  • 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 7938781
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T22:54:17+00:00 2026-06-03T22:54:17+00:00

So I have a function call classifier that basically check all text file in

  • 0

So I have a function call classifier that basically check all text file in a directory, if there is any text file contains more than 50 line of words, then classify that text file into a type using other class called Text_Classification which I am sure its correct and error free. After classification, I will need to clean that text file and write a “Lines” as a first new line on that text file (this is for other class, so dont bother 🙂 ).
But I got an exception, which mean there is something wrong in the try{} block.

Any idea why?

static void classifer(object state) {
    Console.WriteLine("Time to check if any log need to be classified");
    string[] filename = Directory.GetFiles(@"C:\Users\Visual Studio 2010\Projects\server_test\log");
    foreach(string textfile_name in filename) {
        var lineCount = File.ReadAllLines(textfile_name).Length;
        if(lineCount > 50) {
            Console.WriteLine("Start classifying 1 of the logs");
            Text_Classification classifier = new Text_Classification(textfile_name, 1);
            string type = classifier.passBack_type();  //this function passes back the type of the log(text file)
            Console.WriteLine(type);
            try {
                TextWriter tw = new StreamWriter(textfile_name); //clean the text file
                tw.WriteLine(" ");
                tw.Close();
                TextWriter tw2 = new StreamWriter(textfile_name, true);  //append <Lines> as the first new line on the text file
                tw2.WriteLine("Lines");
                tw2.Close();
            }
            catch {
                Console.WriteLine("cant re-write txt");
            }
        }
    }
}
  • 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-03T22:54:19+00:00Added an answer on June 3, 2026 at 10:54 pm

    As discussed, this line is the culprit:

    Text_Classification classifier = new Text_Classification(textfile_name, 1);
    

    The class Text_Classification is opening and not closing the file textfile_name.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I would like to have a function that can wrap any other function call.
I have function getCartItems in cart.js and I want to call that function in
I have a C program which has a function call that is defined in
I have a variable that I'm using to build a JavaScript function call, and
I have a function in R that I call multiple times. I want to
I have a function that i need to call on iframe mousemove(). But i
I have a function call in a program that I'm maintaining has 28 arguments
I have a function call in a query, and that result has to be
I have a function that I call with ?clear-cart appended to the end of
Is it possible to have a function that takes a foreign function call where

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.