SlideShare a Scribd company logo
1 of 7
C# Tutorial
Part 31:File string
www.siri-kt.blogspot.com
• A file is a collection of data stored in a disk with a
specific name and a directory path. When a file is
opened for reading or writing, it becomes a stream.
• The stream is basically the sequence of bytes passing
through the communication path. There are two main
streams: the input stream and theoutput stream.
The input stream is used for reading data from file
(read operation) and the output stream is used for
writing into the file (write operation).
• C# I/O Classes
• The System.IO namespace has various classes that are
used for performing numerous operations with files,
such as creating and deleting files, reading from or
writing to a file, closing a file etc.
• The following table shows some commonly used non-
abstract classes in the System.IO namespace:
• C# FileStream
• C# FileStream class provides a stream for file
operation. It can be used to perform synchronous and
asynchronous read and write operations. By the help of
FileStream class, we can easily read and write data into
file.
• C# FileStream example: writing single byte into file
• Let's see the simple example of FileStream class to
write single byte of data into file. Here, we are using
OpenOrCreate file mode which can be used for read and
write operations.
• C# StreamWriter
• C# StreamWriter class is used to write characters to a
• C# StreamReader
• C# StreamReader class is used to read string from the
stream. It inherits TextReader class. It provides Read()
and ReadLine() methods to read data from the stream.
• C# Serialization
• In C#, serialization is the process of converting object
into byte stream so that it can be saved to memory, file
or database. The reverse process of serialization is
called deserialization.
• Serialization is internally used in remote applications.
• C# SerializableAttribute
• To serialize the object, you need to
apply SerializableAttribute attribute to the type. If you
don't apply SerializableAttribute attribute to the
type, SerializationException exception is thrown at
• C# Deserialization
• In C# programming, deserialization is the reverse
process of serialization.
• It means you can read the object from byte
stream. Here, we are going to
use BinaryFormatter.Deserialize(stream) method
to deserialize the stream.
For more visit our website www.siri-kt.blogspot.com
Thanks for
Watching
More Angular JS TutorialsMore C sharp (c#) tutorials

More Related Content

What's hot

Microsoft power point chapter 5 file edited
Microsoft power point   chapter 5 file editedMicrosoft power point   chapter 5 file edited
Microsoft power point chapter 5 file editedLinga Lgs
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52myrajendra
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDipayan Sarkar
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handlingDeepak Singh
 
File system interface
File system interfaceFile system interface
File system interfaceDayan Ahmed
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams Ahmed Farag
 
Itp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & OutputItp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & Outputphanleson
 
Cosc 2425 – programming project 3 write an assembly language prog
Cosc 2425 – programming project 3 write an assembly language progCosc 2425 – programming project 3 write an assembly language prog
Cosc 2425 – programming project 3 write an assembly language progRAJU852744
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1sotlsoc
 
File access methods.54
File access methods.54File access methods.54
File access methods.54myrajendra
 
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OCore Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OWebStackAcademy
 

What's hot (19)

Microsoft power point chapter 5 file edited
Microsoft power point   chapter 5 file editedMicrosoft power point   chapter 5 file edited
Microsoft power point chapter 5 file edited
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Character stream classes .52
Character stream classes .52Character stream classes .52
Character stream classes .52
 
File handling
File handlingFile handling
File handling
 
Deletion of a Record from a File - K Karun
Deletion of a Record from a File - K KarunDeletion of a Record from a File - K Karun
Deletion of a Record from a File - K Karun
 
Chapter28 data-file-handling
Chapter28 data-file-handlingChapter28 data-file-handling
Chapter28 data-file-handling
 
Javaio
JavaioJavaio
Javaio
 
File handling
File handlingFile handling
File handling
 
File system interface
File system interfaceFile system interface
File system interface
 
File handling
File handlingFile handling
File handling
 
Md121 streams
Md121 streamsMd121 streams
Md121 streams
 
C++ Files and Streams
C++ Files and Streams C++ Files and Streams
C++ Files and Streams
 
Chapter 6
Chapter 6Chapter 6
Chapter 6
 
Itp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & OutputItp 120 Chapt 19 2009 Binary Input & Output
Itp 120 Chapt 19 2009 Binary Input & Output
 
Cosc 2425 – programming project 3 write an assembly language prog
Cosc 2425 – programming project 3 write an assembly language progCosc 2425 – programming project 3 write an assembly language prog
Cosc 2425 – programming project 3 write an assembly language prog
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
File access methods.54
File access methods.54File access methods.54
File access methods.54
 
Filehandling
FilehandlingFilehandling
Filehandling
 
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/OCore Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
Core Java Programming Language (JSE) : Chapter XI - Console I/O and File I/O
 

Similar to 31cs

32sql server
32sql server32sql server
32sql serverSireesh K
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfVithalReddy3
 
L21 io streams
L21 io streamsL21 io streams
L21 io streamsteach4uin
 
ASP.NET Session 7
ASP.NET Session 7ASP.NET Session 7
ASP.NET Session 7Sisir Ghosh
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2Gera Paulos
 
inputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfinputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfhemanth248901
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++jamilmalik19
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxSadhilAggarwal
 
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptxChapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptxnoonoboom
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization Hitesh-Java
 
Session 22 - Java IO, Serialization
Session 22 - Java IO, SerializationSession 22 - Java IO, Serialization
Session 22 - Java IO, SerializationPawanMM
 

Similar to 31cs (20)

32sql server
32sql server32sql server
32sql server
 
CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdf
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
IOStream.pptx
IOStream.pptxIOStream.pptx
IOStream.pptx
 
Input & output
Input & outputInput & output
Input & output
 
null.pptx
null.pptxnull.pptx
null.pptx
 
ASP.NET Session 7
ASP.NET Session 7ASP.NET Session 7
ASP.NET Session 7
 
Java I/O
Java I/OJava I/O
Java I/O
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
inputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdfinputoutputstreams-140612032817-phpapp02.pdf
inputoutputstreams-140612032817-phpapp02.pdf
 
Input output streams
Input output streamsInput output streams
Input output streams
 
CPP17 - File IO
CPP17 - File IOCPP17 - File IO
CPP17 - File IO
 
Exception Handling ,templates in C++
Exception Handling ,templates in C++Exception Handling ,templates in C++
Exception Handling ,templates in C++
 
CHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptxCHAPTER 5 mechanical engineeringasaaa.pptx
CHAPTER 5 mechanical engineeringasaaa.pptx
 
ch09.ppt
ch09.pptch09.ppt
ch09.ppt
 
cs8251 unit 1 ppt
cs8251 unit 1 pptcs8251 unit 1 ppt
cs8251 unit 1 ppt
 
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptxChapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
Chapter 13_m5JAVANOTESAPPLETS,INPUT.pptx
 
05io
05io05io
05io
 
Java IO, Serialization
Java IO, Serialization Java IO, Serialization
Java IO, Serialization
 
Session 22 - Java IO, Serialization
Session 22 - Java IO, SerializationSession 22 - Java IO, Serialization
Session 22 - Java IO, Serialization
 

More from Sireesh K (20)

Cn10
Cn10Cn10
Cn10
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
chanakya neeti
chanakya neetichanakya neeti
chanakya neeti
 
What is mvc
What is mvcWhat is mvc
What is mvc
 
31c
31c31c
31c
 
45c
45c45c
45c
 
44c
44c44c
44c
 
43c
43c43c
43c
 
42c
42c42c
42c
 
41c
41c41c
41c
 
40c
40c40c
40c
 
39c
39c39c
39c
 
38c
38c38c
38c
 
37c
37c37c
37c
 
35c
35c35c
35c
 
34c
34c34c
34c
 
33c
33c33c
33c
 
30c
30c30c
30c
 
29c
29c29c
29c
 
27c
27c27c
27c
 

Recently uploaded

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfadityarao40181
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon AUnboundStockton
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17Celine George
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceSamikshaHamane
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfUjwalaBharambe
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxthorishapillay1
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...Marc Dusseiller Dusjagr
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxOH TEIK BIN
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupJonathanParaisoCruz
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentInMediaRes1
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxpboyjonauth
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxmanuelaromero2013
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxGaneshChakor2
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,Virag Sontakke
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTiammrhaywood
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxRaymartEstabillo3
 

Recently uploaded (20)

Biting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdfBiting mechanism of poisonous snakes.pdf
Biting mechanism of poisonous snakes.pdf
 
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Tilak Nagar Delhi reach out to us at 🔝9953056974🔝
 
Crayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon ACrayon Activity Handout For the Crayon A
Crayon Activity Handout For the Crayon A
 
How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17How to Configure Email Server in Odoo 17
How to Configure Email Server in Odoo 17
 
Roles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in PharmacovigilanceRoles & Responsibilities in Pharmacovigilance
Roles & Responsibilities in Pharmacovigilance
 
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdfFraming an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
Framing an Appropriate Research Question 6b9b26d93da94caf993c038d9efcdedb.pdf
 
Proudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptxProudly South Africa powerpoint Thorisha.pptx
Proudly South Africa powerpoint Thorisha.pptx
 
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
“Oh GOSH! Reflecting on Hackteria's Collaborative Practices in a Global Do-It...
 
Solving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptxSolving Puzzles Benefits Everyone (English).pptx
Solving Puzzles Benefits Everyone (English).pptx
 
MARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized GroupMARGINALIZATION (Different learners in Marginalized Group
MARGINALIZATION (Different learners in Marginalized Group
 
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdfTataKelola dan KamSiber Kecerdasan Buatan v022.pdf
TataKelola dan KamSiber Kecerdasan Buatan v022.pdf
 
OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...OS-operating systems- ch04 (Threads) ...
OS-operating systems- ch04 (Threads) ...
 
Alper Gobel In Media Res Media Component
Alper Gobel In Media Res Media ComponentAlper Gobel In Media Res Media Component
Alper Gobel In Media Res Media Component
 
Introduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptxIntroduction to AI in Higher Education_draft.pptx
Introduction to AI in Higher Education_draft.pptx
 
How to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptxHow to Make a Pirate ship Primary Education.pptx
How to Make a Pirate ship Primary Education.pptx
 
CARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptxCARE OF CHILD IN INCUBATOR..........pptx
CARE OF CHILD IN INCUBATOR..........pptx
 
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,भारत-रोम व्यापार.pptx, Indo-Roman Trade,
भारत-रोम व्यापार.pptx, Indo-Roman Trade,
 
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPTECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
ECONOMIC CONTEXT - LONG FORM TV DRAMA - PPT
 
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝Model Call Girl in Bikash Puri  Delhi reach out to us at 🔝9953056974🔝
Model Call Girl in Bikash Puri Delhi reach out to us at 🔝9953056974🔝
 
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptxEPANDING THE CONTENT OF AN OUTLINE using notes.pptx
EPANDING THE CONTENT OF AN OUTLINE using notes.pptx
 

31cs

  • 1. C# Tutorial Part 31:File string www.siri-kt.blogspot.com
  • 2. • A file is a collection of data stored in a disk with a specific name and a directory path. When a file is opened for reading or writing, it becomes a stream. • The stream is basically the sequence of bytes passing through the communication path. There are two main streams: the input stream and theoutput stream. The input stream is used for reading data from file (read operation) and the output stream is used for writing into the file (write operation). • C# I/O Classes • The System.IO namespace has various classes that are used for performing numerous operations with files, such as creating and deleting files, reading from or writing to a file, closing a file etc. • The following table shows some commonly used non- abstract classes in the System.IO namespace:
  • 3. • C# FileStream • C# FileStream class provides a stream for file operation. It can be used to perform synchronous and asynchronous read and write operations. By the help of FileStream class, we can easily read and write data into file. • C# FileStream example: writing single byte into file • Let's see the simple example of FileStream class to write single byte of data into file. Here, we are using OpenOrCreate file mode which can be used for read and write operations. • C# StreamWriter • C# StreamWriter class is used to write characters to a
  • 4. • C# StreamReader • C# StreamReader class is used to read string from the stream. It inherits TextReader class. It provides Read() and ReadLine() methods to read data from the stream. • C# Serialization • In C#, serialization is the process of converting object into byte stream so that it can be saved to memory, file or database. The reverse process of serialization is called deserialization. • Serialization is internally used in remote applications. • C# SerializableAttribute • To serialize the object, you need to apply SerializableAttribute attribute to the type. If you don't apply SerializableAttribute attribute to the type, SerializationException exception is thrown at
  • 5.
  • 6. • C# Deserialization • In C# programming, deserialization is the reverse process of serialization. • It means you can read the object from byte stream. Here, we are going to use BinaryFormatter.Deserialize(stream) method to deserialize the stream.
  • 7. For more visit our website www.siri-kt.blogspot.com Thanks for Watching More Angular JS TutorialsMore C sharp (c#) tutorials