C# Tutorials and offshore development in India
    Tutorials   Resources   Forum   Interview   Jobs   Projects   Offshore Development    
Code Converter | Articles | Code Factory | Computer Jokes | Members | Peer Appraisal | IT Companies | Revenue Sharing | Talk to Us |



My Profile

Gifts

Active Members
TodayLast 7 Days more...








C# sample for basic file operations



Basic File Operation





Download Sample .NET Project for FileOperations



This chapter will teach you the basic file operations. In the attached sample application, you can type some text and save into a text file. Also, you can select a text file and display the content in a textbox.

In addition to the basic file operations, you can learn some good programming practices and error handling/validation techniques.

This chapter and the attached sample application demonstrates the usage of following .NET classes and methods:

  • System.IO.Path.GetExtension() - Method to check the extension of a file.
  • System.IO.File.Exists() - Check if a file alread exists.
  • System.Windows.Forms.OpenFileDialog - "File Open Dialog" to choose a file from the disk.
  • DialogResult.OK - Result from a File Open Dialog.
  • MessageBox.Show() - Displaying a message to the user.
  • string.Trim() - Remove white space characters from beginning and end of string.
  • throw new Exception() - Create and throw a new exception.
  • System.IO.StreamWriter - Stream writer to write into files.
  • System.IO.StreamReader - Read from file.
  • Application.Exit() - Closing an application.








    Next Chapter: C# sample for retrieving html content from any websites


    Previous Chapter: Displaying Simple MessageBox


    Tutorial Index




  • Read TATA Nano reviews.
    dotNet Slackers   BizTalk Adaptors    Web Design   Scripts
    Are you waiting for engineering entrance result? Watch here for engineering entrance results.
    silicone halloween masks

    Contact Us    Privacy Policy    Terms Of Use