Monday 3 March 2014

What is File Handaling in C#.net

File handling :

All the classes are related to file handling reside "System.IO" Namespace.Data can be retrieve from Database and File.Database is basically for the handling of data in an efficient and safe manner, but in the case of the file we're used to process data more efficiently as database does not.
File Handling with one Real application .Which is given below:

1 .Create:- In this mode New file will be created. If File is Exist then It will be Overridden.
2. Append:- In Append mode Existing File be open and contents will be written from Last. If File not Exist then new File will be created. This mode is used Between two Files.
3. Create New:- In this mode New File wiil be created, if File is already Exist then it will thrown Exception.
4. Truncate:- In this Existing File will be open and Entire contents of the File will be removed.


Each of them will be discussed by the example file is used Operations.I are some important categories.
  • File Stream:- It supports both Read and Write operations in a File.
  • File Info:-It supports creation,deletion open and moving of files using File Stream object.We can not inherit File Info class from other class.
  • Directory Info:- It is same as File Info class but it is used for Directory operations(create,move,enumerate etc.).We can not inherit Directory Info class from other class.
  • Binary Reader:- It supports to Read Primitives Data Types same as binary values .
  • Binary Writer:- it supports to write the primitive Data Types in Binary to a stream.
  • Stream Reader:- It supports to Read characters from Byte stream.
  • Stream Writer:-It supports to Write characters in the string Buffer.
  • Text Reader:-It is used for reading the sequential series of characters.
  • Text Writer:-It is used for writing the sequential series of characters.
  • Memory Stream:- It supports to creates a stream in Memory .
  • Drive Info:- It supports to access the information from a drive.
  • File Access:-It supports Read,Write access to a File.
1. Stream Reader Class:-
  • Flush():-Flush function is used for immediately save the File contents from Buffer to Memory.
  • Close():-Close function is used for closing the file.If we do not write close() statement in our program then File will be always open mode ,then No other person will be used this File at that time. This is the reason for using close statement in  the File Program.
  • Read():-It is used for Reading the Value using File Stream.
  • Read-Line():-It is used  for Read  the value  using File Stream in a File Line by Line.
  • Peek():-It returns next value but not use it.
  • Seek():-It is used for Read/Write a values at any positions in a file.
2.Stream Writer Class:-
  • close()-->Close function is used for closing the file.
  • Flush():-Flush function is used for immediately save the File contents from Buffer to Memory.
  • Write():- It is used for writing a File using File stream class.
  • Write Line():- It is used to write a File Line by Line using File stream.
File handling is mechanism to store the data permanent in the disk. 
it is stream abstract class used.
Stream is base class so many class is derive stream.


There are some steps to perform this three tasks.Follow step by step which is given below:
Step :1  First open Your visual studio-->File -->New-->Project-->Select Windows Forms Application-->OK.
Step :2 Now make this Design using controls which is as shown below:
Step :3 Now  double click on Buttons(Write,Read,Find) one by one and write the following codes which is given below:



















0 comments:

Post a Comment