good day everyone!

i have a problem...

i have 27 text files in a folder named dito... and every minute there will be new text file in a folder...

i need to create a program that saves a record locator(9-digit-code)...

the rule is that there will be no human interactions..

once the program is opened,,, it will automatically open the text files one by one in the folder named dito and save the 9-digit-code(record locator) which is located in line 4 beside MUC1A(note: this is a consistent data... all of the text files that will go in the folder will contain this MUC1A data..)

then it will automatically save the 9-digit-code in the database and move the textfile to another folder name trash and delete its copy in the folder named dito...

it should be a continues process that will not stop unless the folder named dito will no longer receive a textfile

who can help me? please my deadline is tomorrow and i'm new in c sharp programming and in using asp.net 3.5 windows application

here's the code that i started but it's not yet finish

my code just open a single textfile and show the 9 digit code in a label1.text

using System;
using System.IO;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using ftl.DataSet1TableAdapters;



namespace ftl
{
    public partial class Form1 : Form
    {
        ReLocTableAdapter rs = new ReLocTableAdapter();
        public Form1()
        {
            InitializeComponent();
        }

        private void Form1_Load(object sender, EventArgs e)
        {
            string file_name = "C:\\dito\\AIR41391.txt";

            if (System.IO.File.Exists(file_name) == true)
            {

                System.IO.StreamReader objReader;
                objReader = new System.IO.StreamReader(file_name);

                textBox1.Text = objReader.ReadToEnd();

                objReader.Close();
            }

            string str = textBox1.Text;
            string retString = "MUC1A";
            str = textBox1.Text;
            retString = str.Substring(111,9);
            label1.Text= retString;
            


            rs.InsertQuery(label1.Text);

        }

        }

        
    }

1. You should be using FileSystemWatcher to wait for files.
2. Since your requirement is to read a text file line by line, you can use StringReader, using which you can read a file line by line.

Be a part of the DaniWeb community

We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.