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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T21:10:35+00:00 2026-06-12T21:10:35+00:00

To read i tried this code: In the top of Form1 i did: Dictionary<string,

  • 0

To read i tried this code:

In the top of Form1 i did:

Dictionary<string, List<string>> LocalyKeyWords = new Dictionary<string, List<string>>();

In the constructor i did:

keywords = @"d:\Keywords.txt";
            if (File.Exists(keywords))
            {
                LoadKeys(LocalyKeyWords, keywords);
            }

The function LoadKeys:

private void LoadKeys(Dictionary<string,List<string>> disctionary, string FileName)
        {
            var lines = File.ReadAllLines(keywords).Select(l => l.Split(','));
            var dict = new Dictionary<string, List<string>>();
            foreach(var splits in lines)
            {
                var key = splits.First();
                var value = splits.Skip(1).ToList();
                try {dict.Add(key, value);
                }
                catch(Exception ex)
                {  } } 
        }

No exceptions but in the constructor after calling the function and all is done the LocalyKeyWords is empty.


This is how im writing to the file today the keys and values:

private void button6_Click(object sender, EventArgs e)
        {

            using (var w = new StreamWriter(keywords))
            {
                crawlLocaly1 = new CrawlLocaly();
                crawlLocaly1.StartPosition = FormStartPosition.CenterParent;
                DialogResult dr = crawlLocaly1.ShowDialog(this);
                if (dr == DialogResult.OK)
                {
                    if (LocalyKeyWords.ContainsKey(mainUrl))
                    {
                        LocalyKeyWords[mainUrl].Clear();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    else
                    {
                        LocalyKeyWords[mainUrl] = new List<string>();
                        LocalyKeyWords[mainUrl].Add(crawlLocaly1.getText());
                    }
                    foreach (KeyValuePair<string, List<string>> kvp in LocalyKeyWords)
                    {
                        w.WriteLine(kvp.Key + "," + string.Join(",", kvp.Value));
                    }
                }
            } 
        }

Maybe now you will be able to solve the loading the keys and values in the constructor and also to solve the problem how to write each time im doing a change of the keys or values in the button6 click event.

  • 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-12T21:10:37+00:00Added an answer on June 12, 2026 at 9:10 pm
    string line = System.String.Empty;
    using (StreamReader sr = new StreamReader("MyFile.txt")
    {
        while ((line = sr.ReadLine()) != null)
        {
             string[] tokens = line.Split(',');    
             LocalKeyWords.Add(tokesn[0], tokens[1]);
        }
    }
    

    You should probably wrap that in a try catch as well.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

how to make php can read log file in /var/log/.... I tried this code
I just read the top answer at this post: Problem inserting string or NULL
I want to read an xml file placed in assets/ directory. I've tried this
I read Japanese, and want to try processing some Japanese text. I tried this
I tried to implement this example to write and read data from internal storage,
I tried to read a file in a view like this: def foo(request): f
after read this article i tried generate EF model by System.Diagnostics.Process: Process myProcess =
I have read numerous people with this question and have tried numerous strategies. However,
Questions exactly like this have been asked before, i've read them all and tried
I've read all the other threads and tried everything. Here's where I'm at: Constructor:

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.