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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T16:10:35+00:00 2026-05-21T16:10:35+00:00

I am trying to create following. My app is windows app and form contains

  • 0

I am trying to create following.

My app is windows app and form contains following

  1. two text boxes one for name and another for comments
  2. date time picker
  3. set and reset button.

now my app needs to work like following.

When i open my app it needs to show me the message reminding abt comments and name who made comment specifying date.

for this i m not using any DataBase i created file to store comments and name and date.

so my problem is how i should read text distinguishing name ,comments and date.

my code is as follows:

using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;
namespace DateUpdater.Classes
{
    public class FileHandling
    {

        public bool WritetoFile(Classes.FileParameters Params)
        {


            string directoryPath = Environment.CurrentDirectory.ToString();

                 directoryPath = directoryPath.ToLower().Replace("\\bin\\debug", "\\Logs\\reminder.txt");
                File.AppendAllText(directoryPath, Params.Comments.ToString());

                File.AppendAllText(directoryPath, EndCharacter());
                File.AppendAllText(directoryPath, Params.Name.ToString());
                File.AppendAllText(directoryPath, EndCharacter());
                File.AppendAllText(directoryPath, Params.DateToSet.ToString());
                File.AppendAllText(directoryPath, EndCharacter());

                return true;

        }

        public Classes.FileParameters ReadFromFile()
        {
            Classes.FileParameters Params;
            string directoryPath = Environment.CurrentDirectory.ToString();

            directoryPath = directoryPath.ToLower().Replace("\\bin\\debug", "\\Logs\\reminder.txt");
          // string tempData= File.ReadAllText(directoryPath);
           var searchTarget = "/n";
           foreach (var line in File.ReadLines(directoryPath))
           {
               if (line.Contains(searchTarget))
               {

                   break; // then stop
               }
           }

           return null; 

        }

        public string EndCharacter()
        {
            return "/n";
        }

    }
}

please give me the solution…

  • 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-21T16:10:36+00:00Added an answer on May 21, 2026 at 4:10 pm

    Using AppendAllText is suboptimal, since msdn says it opens/creates and closes a file every time you call it. In your example, you’d open and close a file six times. File.AppendText will be a better alternative. If you drop your custom line separators and use the system default, you could do this:

    public bool WritetoFile(Classes.FileParameters Params)
    {
        string directoryPath = Environment.CurrentDirectory.ToString();
    
        directoryPath = directoryPath.ToLower().Replace("\\bin\\debug", "\\Logs\\reminder.txt");
        using(StreamWriter stream = File.AppendText(directoryPath))
        {
            stream.Write(Params.Comments.ToString());
            stream.Write(SepCharacter);
            stream.Write(directoryPath, Params.Name.ToString());
            stream.Write(SepCharacter);
            stream.WriteLine(directoryPath, Params.DateToSet.ToString());
        }
        return true;
    }
    
    public char SepCharacter { get{ return '\t'; } }
    

    This will put all your content in a single line in your text file, separated by a tab. The line separator is the default \r\n. Make sure you use separator characters that won’t appear within your text, otherwise you need to mask/unmask them in your WritetoFile/ReadFromFile routines.
    And then you could do

    public Classes.FileParameters ReadFromFile()
    {
        Classes.FileParameters Params;
        string directoryPath = Environment.CurrentDirectory.ToString();
    
        directoryPath = directoryPath.ToLower().Replace("\\bin\\debug", "\\Logs\\reminder.txt");
        var searchTarget = "searchString";
        foreach (var line in File.ReadLines(directoryPath))
        {
           if (line.Contains(searchTarget))
            {
                // this will give you a string array of Comment, Name and Date
                // for every line that contains "searchString"
                string[] data = line.Split( new char[] { SepCharacter } );
    
                break; // then stop
            }
        }
    
        return null; 
    }
    

    In case your comments can contain line feeds or tabs, this needs some more work regarding masking/unmasking those. But that problem exists in your intial example too as well.

    By the way, sorry for any typos, I did this in Notepad 😉

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

Sidebar

Related Questions

I am trying to create an android app that has the following: Theme set
I'm using SharpDX and XAudio2 in a Windows Store app. I'm trying to create
I'm trying to create a Metro-style app following this guide for a hello, word
I'm trying to create an UWP (Universal Windows App) application with C#. My problem
I am trying to create a metro app based on a Developing windows 8
i'm trying to create following layout: http://jsfiddle.net/BTuMH/1/ but without setting the width, like: http://jsfiddle.net/yuGyg/
i am trying to create an .htaccess file that will achieve the following create
New with Android. Sorry! I'm trying to create the following... Wait for Timer to
I'm trying the following: CREATE TABLE Table1 ( RecordNo autonumber, --error here! PersonId varchar(50),
I'm trying to create a new function in SQL with the following code: CREATE

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.