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 1110239
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 17, 20262026-05-17T02:21:51+00:00 2026-05-17T02:21:51+00:00

I’ve been tasked with writing a c# program which is meant to do the

  • 0

I’ve been tasked with writing a c# program which is meant to do the following:

You input the target directory.
The program searches if the directory exists. If it doesn’t, request new input. Otherwise carry on.

Program gets files of a certain type (it’s meant to be .epl files, but for working this out I’m just using .txt files) and adds them to the FilePathsA[] array.
An Array List is made from FilePathsA.

If the count of the list is 0; get file. (there will only ever be 1 file of its type in said folder).
If the count of the list is 1; take the filepath string, create a text reader instance. Read the text of the file, append the text, send the text to a printer.

Close text reader instance.
Delete the file that was just printed.
Clear the array list.

Repeat the get file process until a new file is found, print/delete that, repeat the cycle. It’s meant to stay active until the program is shut down.

Getting the initial file works fine; it prints then deletes the file from the folder. However my issue is with the recursion in perpetuating this cycle.
Once a file is deleted, it’ll continuously “search” but not actually follow through. Debugging seems to indicate that it’s not getting the new file at all.

Not sure how to go about solving this, here is the code excerpt:
http://pastebin.com/RNn7QqXJ

Any help appreciated!

  • 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-05-17T02:21:52+00:00Added an answer on May 17, 2026 at 2:21 am

    I think you should put

    string[] filePathsA;
    ArrayList filePaths;
    

    outside your loop

    and

    filePathsA = Directory.GetFiles(@dir, "*.txt");
    filePaths = new ArrayList(filePathsA);
    

    inside your do ... while block in its beginning.

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

Sidebar

Related Questions

I have a jquery bug and I've been looking for hours now, I can't
link Im having trouble converting the html entites into html characters, (&# 8217;) i
I am trying to understand how to use SyndicationItem to display feed which is
I used javascript for loading a picture on my website depending on which small
I have a string like this: La Torre Eiffel paragonata all’Everest What PHP function
I would like to run a str_replace or preg_replace which looks for certain words
I'm using v2.0 of ClassTextile.php, with the following call: $testimonial_text = $textile->TextileRestricted($_POST['testimonial']); ... and
I'm parsing an RSS feed that has an ’ in it. SimpleXML turns this
I need to clean up various Word 'smart' characters in user input, including but
I have a text area in my form which accepts all possible characters from

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.