Free shipping on orders of 3000 TL and above!
Developing a Simple Notepad Application with C#

Developing a Simple Notepad Application with C#

Step-by-step guide to building a simple Notepad app in C#: create project, add save and load functionality.

3 min read 1313 views

Developing a Simple Notepad Application with C#

Hello! In this article, we will learn step by step how to develop a simple Notepad application using the C# programming language. This application will allow users to create, edit, and save text-based notes.

Step 1: Creating the Project and Designing the User Interface

  1. First, create a C# project in an integrated development environment (IDE). I recommend using an IDE like Visual Studio. Create a new project named "NotDefteriUygulamasi".

  2. After creating the project, add a text box and a "Save" button to the main window of your project. These two components will allow users to enter text and enable you to save the entered text.

Step 2: Text Saving Functionality

  1. We will create the click function for the Save button. When the Save button is clicked, we will save the content from the text box to a file.

  2. Double-click the Save button to access the code section that will run when this button is clicked.

  3. Add the following code to the button's click handler:

    private void btnKaydet_Click(object sender, EventArgs e)
    {
        try
        {
            string notIcerik = txtNot.Text; // Metin kutusundaki içerik alınıyor.
            string dosyaYolu = "not.txt"; // Notların kaydedileceği dosyanın yolu belirleniyor.
    
            System.IO.File.WriteAllText(dosyaYolu, notIcerik); // İçerik dosyaya yazılıyor.
            MessageBox.Show("Not kaydedildi."); // Kullanıcıya bilgi veriliyor.
        }
        catch (Exception ex)
        {
            MessageBox.Show("Hata: " + ex.Message); // Hata durumunda kullanıcıya hata mesajı gösteriliyor.
        }
    }
    

Step 3: Text Loading Functionality

  1. Now, we need to ensure that the application loads previously saved notes when it starts.

  2. To call this function when the form loads, follow these steps. Return to the form design and open the properties window to view the events of the main window. Find the "Load" event and double-click it to go to the code editor.

  3. Add the following code inside this event:

private void YukleNot()
{
    string dosyaYolu = "not.txt"; // Okunacak dosyanın yolu belirleniyor.

    if (System.IO.File.Exists(dosyaYolu))
    {
        string notIcerik = System.IO.File.ReadAllText(dosyaYolu); // Dosya içeriği okunuyor.
        txtNot.Text = notIcerik; // Metin kutusuna içerik yazdırılıyor.
    }
}

private void MainForm_Load(object sender, EventArgs e)
{
    YukleNot(); // Form yüklendiğinde notları yükleme işlevi çağrılıyor.
}

Step 4: Running the Application

When you reach this step, you will have completed a simple Notepad application. When you start your application, you will be able to save and load notes written in the text box.

This application can be a great example to understand and use the basic features of the C# programming language. In the future, you can design more advanced applications by using these basic structures when developing more complex projects.

Share
Back to all posts

Comments

No comments yet. Be the first to write one.

Your email is not published. Comments are reviewed before publishing.

Similar Posts

What is C#? What Does It Do?

What is C#, what is it used for, and where is it used? Learn about Microsoft's object-oriented language C# and its applications in desktop,…

Read More

C# File Renaming Application

Learn step by step how to develop a Windows Forms-based bulk file renaming application with C#. Simplify your file management tasks.

Read More

Developing a Todo List Application with C#

In this guide, you will learn step by step how to develop a to-do list application using C#, including how to use text boxes and buttons. Yo…

Read More
Fast Shipping All orders placed before 15:00 on weekdays are shipped the same day.
Secure Shopping All your information is protected with a 256-bit SSL certificate.
Expert Technical Service Professional maintenance and repair for your products.
Free Shipping No shipping fee on orders above a certain amount.

Subscribe to Our Newsletter

Be the first to hear about campaigns and deals.

Kuruköprü Mah. Sefa Özler Cad. özden İşmerkezi kat 7/74 Seyhan / adana

Payment Methods

Visa Mastercard Debit Card World

©2017 - 2026 All rights reserved.