Group Discounts available for 3+ students and Corporate Clients

Working with Stream Reader and Stream Writer class in C#

Working with Stream Reader and Stream Writer class:-

 

  1. Stream Reader is used to read the data from a file.
  2. Stream Writer is used to write the data information in to file.

 

Methods of Stream Reader and Stream Writer classes:-

1

 

 

String S = “String /n ;  String /n………..”

Write (“abc”);

Write (“xyz”);

Abc  xyz

 

What is DOCK?

 

  1. This is a property , which is available for all visible controls.
  2. Dock property resizes a control Relatively with form Size.

 

What is Anchor?

  1. Anchor property repositions a control relatively with form size

 

  • Developing An application like a notepad
  • Options required in note pad

 

File                   Edit                  Format                         Help

New                 Select all            Fonts                      Help topics

Open                   Cut                   Colors                      About

Save                    Copy

Print                     Paste

Exit

 

 

The following controls are required to develop notepad

 

  1. Text Box
  2. Menu Strip
  3. Open File Dialog
  4. Save File Dialog
  5. Print Dialog
  6. Color Dialog
  7. Font Dialog

 

 

  • Open windows Forms Application Project name my note
  • Place all above 7 controls on the form
  • Choose text box arrrowpropertiesarrrow

Multiline = true

Dock = fill

Scrollbars = both

Allow drop = true

  • Select Menu strip control and design it with above  discussed options
  • Assigning an Icon   to a menu item

Right click on new arrrowset Image arrrowchoose an image

  • Assigning a short – cut key

Right click on cut arrrow properties arrrow short cut key

  • Select a combination

{

Using System . Io;

Using System . Drawing .Printing

}

 

Code for new menu Item  (double click on new)

{

Text Box1. Text = “”;

}

Code for  open menu Item

{

Open File Dialog 1. Show Dialog ();

String p = Open File Dialog 1. File Name;

Message box. Show  (p);

Stream Reader sr = new Stream Reader  (p);

Text box 1 .text = sr. Read To end ();

Sr. close ();

}

Code for save menu item

{

Save File Dialog 1. Show Dialog ();

String p = Save File Dialog 1 .File Name;

Stream Writer sw = new Stream Writer (p);

Sw. Write  (text box1. text);

Sw. Flush ();

Sw. Close ();

}

Code for Print

{

Printer Setting ps = new Printer Settings ();

Print Dialog 1 .Printer Strings = ps;

Print Dialog1. Show Dialog ();

}

Code for exit

{

Application .Exit ();

}

Code for Select ALL

{

Text box1.Select ALL();

}

 

 

  • Code for cut

text box 1.cut ();

  • Code for copy

text box1.copy ();

  • Code for paste

textbox1.paste ();

  • Code for Fonts

Font Dialog1 .Show Dialog ();

Text box 1. Font = font Dialog1. Font;

  • Code for colors

{

Color Dialog1. Show Dialog ();

Text Box 1.fore color Dialog1. Color;

}

  • Code for Help Topics

{

Label L =new label ();

  1. Dock = Dock Style .Fill ;
  2. Font = new Font (“Arial”, 20)
  3. Text = “ Type Help messages here” ;

Form f = new Form ();

  1. control S .Add (L);
  2. Show Dialog ();

}

 

View menu arrrow Solution Explorer arrrowright click on my note (project name) arrrowadd à new itemarrrowAbout box and provide the name test

 

Code for About

{

Test t = new Test ();

  1. Show ();

}

 

 

 

 

 

“At TekSlate, we are trying to create high quality tutorials and articles, if you think any information is incorrect or want to add anything to the article, please feel free to get in touch with us at info@tekslate.com, we will update the article in 24 hours.”

0 Responses on Working with Stream Reader and Stream Writer class in C# .net"

    Leave a Message

    Your email address will not be published. Required fields are marked *

    Support


    Please Enter Your Details and Query.
    Three + 6