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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T08:05:11+00:00 2026-05-28T08:05:11+00:00

Hello I am trying to make a C# program that downloads files but I

  • 0

Hello I am trying to make a C# program that downloads files but I am having trouble with the array.

I have it split up the text for downloading and put it into a 2 level jagged array (string[][]).

Now I split up the rows up text by the | char so each line will be formatted like so:
{filename}|{filedescription}|{filehttppath}|{previewimagepath}|{length}|{source}

when I use short test text to put it into a text box it displays fine in the text box.

IE: a string like test|test|test|test|test|test

but if I put in a real string that I would actually be using for the program to DL files the only way I get the string to display is to iterate through it with a for or foreach loop. If I try to access the data with the index I get an index missing error. (IE array[0])

So this is the code that gets the array to display:

public Form2(string[][] textList, string path)
{
    InitializeComponent();
    textBox1.Text = textBox1.Text + path + Environment.NewLine;
    WebClient downloader = new WebClient();
    foreach (string[] i in textList)
    {
        for(int j=0;j<i.Length;j++)
        {
            textBox1.Text = textBox1.Text + i[j] + Environment.NewLine + @"\\newline" + Environment.NewLine;
        }
    }
}

And then this is the code that gives an index missing error:

public Form2(string[][] textList, string path)
{
    InitializeComponent();
    textBox1.Text = textBox1.Text + path + Environment.NewLine;
    WebClient downloader = new WebClient();
    foreach (string[] i in textList)
    {
        textBox1.Text = textBox1.Text + i[0] + Environment.NewLine;
        textBox1.Text = textBox1.Text + i[1] + Environment.NewLine;
        textBox1.Text = textBox1.Text + i[2] + Environment.NewLine;
        textBox1.Text = textBox1.Text + i[3] + Environment.NewLine;
        textBox1.Text = textBox1.Text + i[4] + Environment.NewLine;
        textBox1.Text = textBox1.Text + i[5] + Environment.NewLine;
    }
}

Any help is this is apreciated I don’t see why I can access they data through a for loop but not directly it just doesn’t make any sense to me.

Also, here is the code that generates the array:

public String[][] finalList(string[] FileList)
{
    String[][] FinalArray = new String[FileList.Length][];
    for (int i = 0; i<FinalArray.Length;i++)
    {
        string[] fileStuff = FileList[i].Split(new char[] {'|'});
        FinalArray[i] = fileStuff;
    }
    return FinalArray;
}
  • 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-28T08:05:12+00:00Added an answer on May 28, 2026 at 8:05 am

    In your first example you are using the actual length of each inner array to do the concatenation. In your second example you are hard coded to the same length yet you said in the intro it was a jagged array.

    Can you show what your input text looks like?

    you are not doing the same concatenation in first and second example so the resulting stings are very different.

            first = "\r\n Crazy Video\r\n\\\\newline\r\nThis Video is absolutly crazy!\r\n\\\\newline\r\nhtt://fakeurl.fake/vidfolder/video.flv\r\n\\\\newline\r\nhtt://fakeurl.fake/imgfolder/img.j‌​pg\r\n\\\\newline\r\n300\r\n\\\\newline\r\nhtt://fakeurl.fake \r\n\\\\newline\r\n"
    
            second = "\r\n Crazy Video\r\nThis Video is absolutly crazy!\r\nhtt://fakeurl.fake/vidfolder/video.flv\r\nhtt://fakeurl.fake/imgfolder/img.j‌​pg\r\n300\r\nhtt://fakeurl.fake \r\n" 
    
    
    using System;
    using NUnit.Framework;
    
    namespace ClassLibrary5
    {
        public class Class1
        {
            [Test]
            public void test()
            {
                var temp = new[]
                               {
                                   " Crazy Video|This Video is absolutly crazy!|htt://fakeurl.fake/vidfolder/video.flv|htt://fakeurl.fake/imgfolder/img.j‌​pg|300|htt://fakeurl.fake "
                               };
                var final = finalList(temp);
                var first = Form1(final, "path");
                var second = Form2(final, "path");
                Assert.IsTrue(first.CompareTo(second) == 0);
            }
    
            public string Form1(string[][] textList, string path)
            {
                string textString = path + Environment.NewLine;
    
                foreach (string[] i in textList)
                {
                    for (int j = 0; j < i.Length; j++)
                    {
                        textString = textString + i[j] + Environment.NewLine + @"\\newline" + Environment.NewLine;
                    }
                }
                return textString;
            }
    
            public string Form2(string[][] textList, string path)
            {
                string textString = path + Environment.NewLine;
    
                foreach (string[] i in textList)
                {
                    textString = textString + i[0] + Environment.NewLine;
                    textString = textString + i[1] + Environment.NewLine;
                    textString = textString + i[2] + Environment.NewLine;
                    textString = textString + i[3] + Environment.NewLine;
                    textString = textString + i[4] + Environment.NewLine;
                    textString = textString + i[5] + Environment.NewLine;
                }
                return textString;
            }
    
            public String[][] finalList(string[] FileList)
            {
                String[][] FinalArray = new String[FileList.Length][];
                for (int i = 0; i < FinalArray.Length; i++)
                {
                    string[] fileStuff = FileList[i].Split(new char[] {'|'});
                    FinalArray[i] = fileStuff;
                }
                return FinalArray;
            }
        }
    }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to make a server/client program where the client sends the text Hello
Hello I'm trying to make a program that check first letter of a word
I'm trying to make a simple program that continually displays and updates a label
hello i am trying to make it so that when you visit my site
hello im new and learning javascript. I'm trying to make a program of addition
hello im trying to make something like github treeslider im new to javascript.. but
I am trying to make a program that will take as input a string
Hello I wish not to disturb but I'm newer to developing program. I'm trying
Hello all im trying to make this slide effect http://tinyurl.com/628z32d but im new to
I'm trying to make my program output a sentence but only if it will

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.