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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T17:43:41+00:00 2026-06-12T17:43:41+00:00

I have this function: private void button6_Click(object sender, EventArgs e) { crawlLocaly1 = new

  • 0

I have this function:

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<string>(new string[]
            {
                crawlLocaly1.getText()
            }
            ));
        } 
        crawlLocaly1.Close();
    }
}

When the user type something to textBox and click ok so the result in the LocalKeyWords which is Dictionary> is like:

In index 0 there will be for example: http://www.google.com“,”google
Where google is the key that belong to the http://www.google.com

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.

First time it’s putting a key for the url second its updating the key for the same url or put a new key for a new url.

So the List should be like this:

index 0 http://www.google.com,google
index 1 http://www.microsoft.com,com

And so on…
And this function 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”);

In fact when I’m using a breakpoint on the List I see on the left the url then , and then I see something else not the keyword:

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

Its not a bug or something it’s just on a breakpoint that’s how I see it. Instead System.Collections.Generic.List`1[System.String] I was suppose to see the keyword for example: google

Any way how do I write the List values to the text file so the text file format will be like this:

0 http://www.google.com,google
1 http://www.microsoft.com,hello
2 http://www.cnet.com,Daniel

0 1 2 present the indexs and url’s present the mainUrl and the right sie present the Keys(keywords the user entered).

And then how do I read back the values from the text file to the lixtBox ?
So when I’m running the program in the constructor it will read the text file and show me in a listBox this format:

url: http://www.google.com --- keword: google
url: http://www.microsoft.com --- keword: hello
url: http://www.cnet.com --- keword: Daniel

So in the listBox the user will see it nicer then in the text file.

  • 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-06-12T17:43:42+00:00Added an answer on June 12, 2026 at 5:43 pm

    You can try this simple code to write to textfile your values:

            int count = 0;
            foreach(KeyValuePair<string, string> kvp in LocalyKeyWords)
            {
                w.WriteLine(count.ToString() + " " + kvp.Key + " " + kvp.Value);
                count++;
            }
            w.Close();
    

    Also you can read that textfile using the following code, I must warn you that it doesn’t check if you have all three strings separated with blank character in textfile. Also, if your text that you are storing has blank characters, you should separate strings in file with some special character.

            TextReader r = new StreamReader(@"d:\test.txt");
            string line = string.Empty;
            while ((line = r.ReadLine()) != null)
            {
                string[] data = line.Split(new char[] { ' ' },  StringSplitOptions.RemoveEmptyEntries);
                ListViewItem lvi = new ListViewItem("url: " + data[1] + " " + data[2]);
                listView1.Items.Add(lvi);
            }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have button call this code private void but_Click(object sender, EventArgs e) { Thread
I have this piece of code in my Silverlight project: private void button1_Click(object sender,
I have the following simple function: private void EnableDisable941ScheduleBButton() { if (this._uosDepositorFrequency.Value != null)
I have a function like this in actionscript3 private function uploadFile(event:MouseEvent):void { var uploader:URLRequest
I have this function in my generator. Private Sub AddBoundedValue(ByVal boundedValue As Object, ByVal
I have a ComboBox with a label function like this one: private function fieldLabelFunction(item:Object):String
I have a private function like this in my controller. private UserDetails GetUserDetails(int userid)
i have a class of this kind Class Car { private $color; public function
I have an array of function callbacks, like this: class Blah { private var
I have to call a function on a button click event like this private

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.