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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T14:22:46+00:00 2026-06-09T14:22:46+00:00

I have a file- message.txt that contains raw data, my application reads the file,

  • 0

I have a file-message.txt that contains raw data, my application reads the file, parses it and displays the data accordingly in the listview. The raw data contains a word called REC UNREAD meaning the record is unread. So for the first time when message is read it is UNREAD and I display such messages in bold. After I read it(Using doubleclick event) the word REC UNREAD should be changed to REC READ. This is what I have I tried, not working though

    private void lvwMessages_MouseDoubleClick_1(object sender, MouseEventArgs e)
    {
        try
        {
            ListViewItem item = lvwMessages.SelectedItems[0];
            if(item.Font.Bold)

                {
                    lvwMessages.SelectedItems[0].Font = new Font(lvwMessages.Font, FontStyle.Regular);
                    string tfile = File.ReadAllText("C:\\message.txt");
                    string m1 = lvwMessages.SelectedItems[0].SubItems[1].Text;
                    string m2 = lvwMessages.SelectedItems[0].SubItems[2].Text;
                    //No idea how to go forward from here

This is a sample line in my text file:

+CMGL: 2,"REC UNREAD","+919030665834","","2012/08/10 17:04:15+22"
sample message

In simple words I should be able to search for the line containing m1 and m2(as in the code) and replace the REC UNREAD with REC READ.

  • 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-09T14:22:47+00:00Added an answer on June 9, 2026 at 2:22 pm

    This should solve your problem–

                ListViewItem item = lvwMessages.SelectedItems[0];
                if(item.Font.Bold)
                    {
                        lvwMessages.SelectedItems[0].Font = new Font(lvwMessages.Font, FontStyle.Regular);
                        string tfile = File.ReadAllText("C:\\message.txt");
                        string m1 = lvwMessages.SelectedItems[0].SubItems[1].Text;
                        string m2 = lvwMessages.SelectedItems[0].SubItems[2].Text;
                        string line = string.Empty;
                        string nfile= "";
                        using (StreamReader sr = new StreamReader("C:\\message.txt"))
                        {
                          while ((line = sr.ReadLine()) != null)
                          {
                              if (line.Contains(m2)) 
                              {
                                  string pline = line;
                                 string result = line.Replace("REC UNREAD", "REC READ");
                                 nfile= tfile.Replace(pline, result);
                              }
                           }
                       sr.Close();
                       }
                    StreamWriter sw = new StreamWriter("C:\\message.txt");
                    {
                        sw.Write(nfile);
                    }
                    sw.Close();                           
                }
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a header message that is brought in from another file (message.txt), and
I have a Message.xaml file that should display a recipient field and a message
I have .txt files that contain the output from a data logger. The data
The code I have is as follows: FILE *txt_file = fopen(data.txt, r); if (txt_file
I am new to javascript and have some data stored in a txt file
I have the following line in a CMakeLists.txt file... else message(FATAL_ERROR Could not locate
I have a .txt file which contains a column of unixtime, like (1322485992.420381000), the
So I have to decrypt a .txt file that is crypted with XOR code
I have long file with the following list: /drivers/isdn/hardware/eicon/message.c//add_b1() /drivers/media/video/saa7134/saa7134-dvb.c//dvb_init() /sound/pci/ac97/ac97_codec.c//snd_ac97_mixer_build() /drivers/s390/char/tape_34xx.c//tape_34xx_unit_check() (PROBLEM)/drivers/video/sis/init301.c//SiS_GetCRT2Data301() /drivers/scsi/sg.c//sg_ioctl()
Once the system is shutdown there will be message in syslog file. I have

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.