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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 22, 20262026-05-22T23:06:19+00:00 2026-05-22T23:06:19+00:00

So I am writing a C# console application. I have a text file that

  • 0

So I am writing a C# console application. I have a text file that I want to send to a database. The plan is to have multiple text files and only one insert. Everything seems to go fine for the first line. Once I get to the 2nd line the array thinks it only has a length of 2.

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;

namespace UKImporter
{
class Program
{
    static void Main(string[] args)
    {
        string[] lines = System.IO.File.ReadAllLines(@"C:\out\output.txt");
        System.Console.WriteLine("Contents of writeLines2.txt =:");

        foreach (string line in lines)
        {
            string sellername, sku, date1, quantity1, date2, asin, date3, date4, FNSKU;
            char[] tabs = { '\t', '\t', '\t', '\t', '\t', '\t', '\t', '\t',  };
            string[] words = line.Split(tabs);
            sellername = words[0];
            sku = words[1];
            date1 = words[2];
            quantity1 = words[3];
            date2 = words[4];
            asin = words[5];
            date3 = words[6];
            date4 = words[7];
            FNSKU = words[8];
            Console.WriteLine("\t" + line);
            UKDataBLL u = new UKDataBLL();
            //u.AddToDatabase(sku, DateTime.Now, Convert.ToInt16(quantity1), DateTime.Now, asin, DateTime.Now, DateTime.Now, FNSKU);

            foreach (string s in words)
            {
                System.Console.WriteLine(s);
            }

        }

        // Keep the console window open in debug mode.
        Console.WriteLine("Press any key to exit.");
        System.Console.ReadKey();

    }
}
}

Edit Here is some text of the file

A2LQ9QFN82X636 ACD_fivecrowns 6/1/11 5:30 0 6/1/11 5:30 B00000IV35 6/1/11 5:30 6/1/11 5:30 X0000PGTT9

A2LQ9QFN82X63 ACD_caylus_magna_carta 6/1/11 5:30 0 6/1/11 5:30 B000N3SOUM 6/1/11 5:30 6/1/11 5:30 X0000PGM23

A2LQ9QFN82X63 AMX_JrSpaceHelmet-LBL 6/1/11 5:30 0 6/1/11 5:30 B0008F6WMM 6/1/11 5:30 6/1/11 5:30 X0000PQBUL

  • 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-22T23:06:20+00:00Added an answer on May 22, 2026 at 11:06 pm

    Using the above code, I created a simple output file step that met your intended structure and your code does correctly parse the file out. Your issue appears to be based on the data

        string[] content = new string[] { "a\tb\tc\td\te\tf\tg\th\ti", "a\tb\tc\td\te\tf\tg\th\ti" };
        System.IO.File.WriteAllLines(@"C:\sandbox\output.txt", content);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a long-running console-based application Sender that sends simple text to STDOUT using
I am writing a .NET console application to upload files. However, I might have
I have an application that imports data read from text files from a directory
If I would want to create a c# application that support multiple languages, how
I'm writing a console application in Visual Basic 2008 Express. I added several text
I need advice on how to have my C# console application display text to
I have a C# console application that logs a lot to the console (using
I am writing a console application using BDE 2006 and I want it to
I'm writing a sample console application in VS2008. Now I have a Console.WriteLine() method
We have a console application (currently .NET) that sends out mail in bulk to

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.