How can i write the values in a List to a text file?
<p>I have this fucntion:</p>

<pre><code>private void button6_Click(object sender, EventArgs e)
{
    crawlLocaly1 = new CrawlLocaly();
    crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
    DialogResult dr = crawlLocaly1.ShowDialog(this);
    if (dr == DialogResult.Cancel)
    {
        crawlLocaly1.Close();
    }
    else if (dr == DialogResult.OK)
    {
        //LocalyKeyWords.Add(crawlLocaly1.getText() + "," + mainUrl);
        if(LocalyKeyWords.ContainsKey(mainUrl)) 
        {
            LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());


        }
        else
        {
            LocalyKeyWords.Add(mainUrl, new List&lt;string&gt;(new string[]
            {
                crawlLocaly1.getText()
            }
            ));
        } 
        crawlLocaly1.Close();
    }
}
</code></pre>

<p>When the user type something to textBox and click ok so the result in the LocalKeyWords wich is Dictionary> is like:</p>

<p>In index 0 there will be for example: <a href="http://www.google.com" rel="nofollow">http://www.google.com</a>","google
Where google is the key that belong to the <a href="http://www.google.com" rel="nofollow">http://www.google.com</a></p>

<p>Now if the user enter a keyword once to the url it will go to the second part and if the user change the key for the same url it will go to the first part else if the user changed the url so it will go to the second part.</p>

<p>First time its puting a key for the url second its updating the key for the same url or put a new key for a new url.</p>

<p>So the List should be like this:</p>

<pre><code>index 0 http://www.google.com,google
index 1 http://www.microsoft.com,com
</code></pre>

<p>And so on...
And this fucntion is working correctly i just need to add the List to a text file on the hard disk.
So in the Form1 level i have streamwriter w = new streamwriter(@"d:\test.txt");</p>

<p>In fact when im using a breakpoint on the List i see on the left the url then , and then i see something else not the keyword:</p>

<pre><code> [0] = {[http://www.google.co.il, System.Collections.Generic.List`1[System.String]]}
</code></pre>

<p>Its not a bug or osmething itsj ust on a breakpoint thats how i see it. Instead System.Collections.Generic.List`1[System.String] i was suppose to see the keyword for example: google</p>

<p>Any way how do i write the List values to the text file so the text file format will be like this:</p>

<pre><code>0 http://www.google.com,google
1 http://www.microsoft.com,hello
2 http://www.cnet.com,Daniel
</code></pre>

<p>0 1 2 present the indexs and url's present the mainUrl and the right sie present the Keys(keywords the user entered).</p>

<p>And then how do i read back the values from the text file to the lixtBox ?
So when im running the program in the constructor it will read the text file and show me in a listBox this format:</p>

<pre><code>url: http://www.google.com --- keword: google
url: http://www.microsoft.com --- keword: hello
url: http://www.cnet.com --- keword: Daniel
</code></pre>

<p>So in the listBox the user will see it nicer then in the text file.</p>

<p>Thanks for the help.</p>
