SlideShare a Scribd company logo
1 of 15
File Program
Session 7
Objectives
 File Namespace.
 Working with file classes.
 StreamWriters and StreamReaders.
 Read & Write file handling program.
Introduction
• Reading and writing files are essential aspects of
many .NET applications.
• Files can be a great way to store data using the .net
application, or they can be used to transfer data
between applications.
STREAMS
• All input and output in the .NET Framework involve
the use of streams.
• A stream is an abstract representation of a serial
device.
• A serial device is something that stores data in a
linear manner and is accessed the same way: one byte
at a time.
• This device can be a disk file, a network channel, a
memory location, or any other object that supports
reading and writing to it in a linear manner.
There are two types of streams:
Output:
 Output streams are used when data is written to
some external destination.
 External destination: a physical disk file, a network
location, a printer, or another program.
Input:
 Input streams are used to read data into memory or
variables that your program can access.
 An input stream can come from almost any source
THE CLASSES FOR INPUT &OUTPUT
• The System.IO namespace contains almost all of the
classes for read & write operation.
• few classes are contained in System.IO.
CLASS
File
Directory
Path
StreamReader
StreamWriter
The File and Directory Classes
• The File and Directory utility classes expose many
static methods for manipulating.
• File classes have some method
METHOD DESCRIPTION
Copy() Copies a file from a source location to a target location.
Create() Creates a file in the specified path.
Delete() Deletes a file.
Open() Returns a FileStream object at the specified path.
Move() Moves a specified file to a new location. You can specify a
different name for the file in the new location.
Directory classes have some method
Path Names and Relative Paths:
 When specifying a path name in .NET code, you can
use either absolute or relative path names.
• An absolute path name explicitly specifies a file or
directory from a known location — such as the C:
drive.
• C:WorkLogFile.txt — this path defines exactly
where the file is, with no ambiguity.
Method Description
CreateDirectory() Creates a directory with the specified path.
Delete() Deletes the specified directory and all the files within it.
 Relative path names are relative to a starting location.
 By using relative path names, no drive or known
location needs to be specified.
• The current working directory was the starting point,
which is the default behavior for relative path names.
• For example, if your application is running in the
C:DevelopmentFileDemo directory and uses the
relative path LogFile.txt, the file references would be
C:DevelopmentFileDemoLogFile.txt.
The StreamWriter Object
• The StreamWriter class enables you to write
characters and strings to a file.
• The StreamWriter class handles the writing to the
FileStream object.
FileStream aFile = new FileStream("Log.txt",
FileMode.CreateNew);
StreamWriter sw = new StreamWriter(aFile);
• A StreamWriter object can also be created directly
from a file:
StreamWriter sw = new StreamWriter("Log.txt", true);
• If this is set to false, then a new file is created or the
existing file is truncated and then opened.
• If it is set to true, then the file is opened and the data
is retained. If there is no file, then a new one is
created.
The StreamReader Object
Input streams are used to read data from an
external source.
StreamReader objects are created in much the
same way as StreamWriter objects.
The StreamReader Object
Input streams are used to read data from an
external source.
StreamReader objects are created in much the
same way as StreamWriter objects.
• StreamReader objects are created in much the same
way as StreamWriter objects.
• FileStream aFile = new FileStream("Log.txt",
FileMode.Open);
• StreamReader sr = new StreamReader(aFile);
• The StreamReader class can be created directly from a string
containing the path to a particular file:
• StreamReader sr = new StreamReader("Log.txt");
Summary
• File program concept.
• Several property of System.IO Namespace.
• Stream concept
• StreamWriter & StreamReader.

More Related Content

What's hot (20)

STAT Requirement Analysis
STAT Requirement AnalysisSTAT Requirement Analysis
STAT Requirement Analysis
 
Checkpoints for data_quality
Checkpoints for data_qualityCheckpoints for data_quality
Checkpoints for data_quality
 
CSV File Manipulation
CSV File ManipulationCSV File Manipulation
CSV File Manipulation
 
Introduction to mongo db
Introduction to mongo dbIntroduction to mongo db
Introduction to mongo db
 
File Handling in Java Oop presentation
File Handling in Java Oop presentationFile Handling in Java Oop presentation
File Handling in Java Oop presentation
 
File handling in c++
File handling in c++File handling in c++
File handling in c++
 
14 file handling
14 file handling14 file handling
14 file handling
 
Indexing
IndexingIndexing
Indexing
 
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
 
File Handling
File HandlingFile Handling
File Handling
 
Streams and Files
Streams and FilesStreams and Files
Streams and Files
 
Filehadnling
FilehadnlingFilehadnling
Filehadnling
 
Basic i/o & file handling in java
Basic i/o & file handling in javaBasic i/o & file handling in java
Basic i/o & file handling in java
 
Chapter 10.1
Chapter 10.1Chapter 10.1
Chapter 10.1
 
Files in java
Files in javaFiles in java
Files in java
 
Filehandlinging cp2
Filehandlinging cp2Filehandlinging cp2
Filehandlinging cp2
 
File Handling in C++
File Handling in C++File Handling in C++
File Handling in C++
 
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
 
File structures
File structuresFile structures
File structures
 
Chapter 10.3
Chapter 10.3Chapter 10.3
Chapter 10.3
 

Similar to File Program Session 7 - StreamWriters and StreamReaders

Similar to File Program Session 7 - StreamWriters and StreamReaders (20)

CSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdfCSE3146-ADV JAVA M2.pdf
CSE3146-ADV JAVA M2.pdf
 
IOStream.pptx
IOStream.pptxIOStream.pptx
IOStream.pptx
 
Advanced programming ch2
Advanced programming ch2Advanced programming ch2
Advanced programming ch2
 
Switching & Multiplexing
Switching & MultiplexingSwitching & Multiplexing
Switching & Multiplexing
 
Intake 38 10
Intake 38 10Intake 38 10
Intake 38 10
 
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
 
Data file handling
Data file handlingData file handling
Data file handling
 
Files in c++
Files in c++Files in c++
Files in c++
 
Chapter 11
Chapter 11Chapter 11
Chapter 11
 
Intake 37 11
Intake 37 11Intake 37 11
Intake 37 11
 
File Handling In C++(OOPs))
File Handling In C++(OOPs))File Handling In C++(OOPs))
File Handling In C++(OOPs))
 
Python file handling
Python file handlingPython file handling
Python file handling
 
31cs
31cs31cs
31cs
 
L21 io streams
L21 io streamsL21 io streams
L21 io streams
 
Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9Filepointers1 1215104829397318-9
Filepointers1 1215104829397318-9
 
15. Streams Files and Directories
15. Streams Files and Directories 15. Streams Files and Directories
15. Streams Files and Directories
 
File Handling In C++
File Handling In C++File Handling In C++
File Handling In C++
 
File system interface
File system interfaceFile system interface
File system interface
 
ch09.ppt
ch09.pptch09.ppt
ch09.ppt
 

More from Sisir Ghosh

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2Sisir Ghosh
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3Sisir Ghosh
 
ASP.NET Session 4
ASP.NET Session 4ASP.NET Session 4
ASP.NET Session 4Sisir Ghosh
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5Sisir Ghosh
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6Sisir Ghosh
 
ASP.NET Session 8
ASP.NET Session 8ASP.NET Session 8
ASP.NET Session 8Sisir Ghosh
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9Sisir Ghosh
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10Sisir Ghosh
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12Sisir Ghosh
 
ASP.NET Session 13 14
ASP.NET Session 13 14ASP.NET Session 13 14
ASP.NET Session 13 14Sisir Ghosh
 
ASP.NET Session 16
ASP.NET Session 16ASP.NET Session 16
ASP.NET Session 16Sisir Ghosh
 
ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2Sisir Ghosh
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1Sisir Ghosh
 
Network security
Network securityNetwork security
Network securitySisir Ghosh
 
Module ii physical layer
Module ii physical layerModule ii physical layer
Module ii physical layerSisir Ghosh
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correctionSisir Ghosh
 
Overview of data communication and networking
Overview of data communication and networkingOverview of data communication and networking
Overview of data communication and networkingSisir Ghosh
 
Application layer
Application layerApplication layer
Application layerSisir Ghosh
 

More from Sisir Ghosh (20)

ASP.NET Session 2
ASP.NET Session 2ASP.NET Session 2
ASP.NET Session 2
 
ASP.NET Session 3
ASP.NET Session 3ASP.NET Session 3
ASP.NET Session 3
 
ASP.NET Session 4
ASP.NET Session 4ASP.NET Session 4
ASP.NET Session 4
 
ASP.NET Session 5
ASP.NET Session 5ASP.NET Session 5
ASP.NET Session 5
 
ASP.NET Session 6
ASP.NET Session 6ASP.NET Session 6
ASP.NET Session 6
 
ASP.NET Session 8
ASP.NET Session 8ASP.NET Session 8
ASP.NET Session 8
 
ASP.NET Session 9
ASP.NET Session 9ASP.NET Session 9
ASP.NET Session 9
 
ASP.NET Session 10
ASP.NET Session 10ASP.NET Session 10
ASP.NET Session 10
 
ASP.NET Session 11 12
ASP.NET Session 11 12ASP.NET Session 11 12
ASP.NET Session 11 12
 
ASP.NET Session 13 14
ASP.NET Session 13 14ASP.NET Session 13 14
ASP.NET Session 13 14
 
ASP.NET Session 16
ASP.NET Session 16ASP.NET Session 16
ASP.NET Session 16
 
ASP.NET System design 2
ASP.NET System design 2ASP.NET System design 2
ASP.NET System design 2
 
ASP.NET Session 1
ASP.NET Session 1ASP.NET Session 1
ASP.NET Session 1
 
Transport layer
Transport layerTransport layer
Transport layer
 
Routing
RoutingRouting
Routing
 
Network security
Network securityNetwork security
Network security
 
Module ii physical layer
Module ii physical layerModule ii physical layer
Module ii physical layer
 
Error detection and correction
Error detection and correctionError detection and correction
Error detection and correction
 
Overview of data communication and networking
Overview of data communication and networkingOverview of data communication and networking
Overview of data communication and networking
 
Application layer
Application layerApplication layer
Application layer
 

Recently uploaded

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):comworks
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxMalak Abu Hammad
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Hyundai Motor Group
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 3652toLead Limited
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking MenDelhi Call girls
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxOnBoard
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024Scott Keck-Warren
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationMichael W. Hawkins
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxnull - The Open Security Community
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationRidwan Fadjar
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreternaman860154
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsMemoori
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024BookNet Canada
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptxLBM Solutions
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticscarlostorres15106
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsEnterprise Knowledge
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking MenDelhi Call girls
 

Recently uploaded (20)

CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):CloudStudio User manual (basic edition):
CloudStudio User manual (basic edition):
 
The Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptxThe Codex of Business Writing Software for Real-World Solutions 2.pptx
The Codex of Business Writing Software for Real-World Solutions 2.pptx
 
Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2Next-generation AAM aircraft unveiled by Supernal, S-A2
Next-generation AAM aircraft unveiled by Supernal, S-A2
 
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
Tech-Forward - Achieving Business Readiness For Copilot in Microsoft 365
 
08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men08448380779 Call Girls In Friends Colony Women Seeking Men
08448380779 Call Girls In Friends Colony Women Seeking Men
 
Maximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptxMaximizing Board Effectiveness 2024 Webinar.pptx
Maximizing Board Effectiveness 2024 Webinar.pptx
 
SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024SQL Database Design For Developers at php[tek] 2024
SQL Database Design For Developers at php[tek] 2024
 
GenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day PresentationGenCyber Cyber Security Day Presentation
GenCyber Cyber Security Day Presentation
 
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptxMaking_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
Making_way_through_DLL_hollowing_inspite_of_CFG_by_Debjeet Banerjee.pptx
 
My Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 PresentationMy Hashitalk Indonesia April 2024 Presentation
My Hashitalk Indonesia April 2024 Presentation
 
Pigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping ElbowsPigging Solutions Piggable Sweeping Elbows
Pigging Solutions Piggable Sweeping Elbows
 
Presentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreterPresentation on how to chat with PDF using ChatGPT code interpreter
Presentation on how to chat with PDF using ChatGPT code interpreter
 
AI as an Interface for Commercial Buildings
AI as an Interface for Commercial BuildingsAI as an Interface for Commercial Buildings
AI as an Interface for Commercial Buildings
 
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
#StandardsGoals for 2024: What’s new for BISAC - Tech Forum 2024
 
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptxE-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
E-Vehicle_Hacking_by_Parul Sharma_null_owasp.pptx
 
Key Features Of Token Development (1).pptx
Key  Features Of Token  Development (1).pptxKey  Features Of Token  Development (1).pptx
Key Features Of Token Development (1).pptx
 
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
Neo4j - How KGs are shaping the future of Generative AI at AWS Summit London ...
 
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmaticsKotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
Kotlin Multiplatform & Compose Multiplatform - Starter kit for pragmatics
 
IAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI SolutionsIAC 2024 - IA Fast Track to Search Focused AI Solutions
IAC 2024 - IA Fast Track to Search Focused AI Solutions
 
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men08448380779 Call Girls In Greater Kailash - I Women Seeking Men
08448380779 Call Girls In Greater Kailash - I Women Seeking Men
 

File Program Session 7 - StreamWriters and StreamReaders

  • 2. Objectives  File Namespace.  Working with file classes.  StreamWriters and StreamReaders.  Read & Write file handling program.
  • 3. Introduction • Reading and writing files are essential aspects of many .NET applications. • Files can be a great way to store data using the .net application, or they can be used to transfer data between applications.
  • 4. STREAMS • All input and output in the .NET Framework involve the use of streams. • A stream is an abstract representation of a serial device. • A serial device is something that stores data in a linear manner and is accessed the same way: one byte at a time. • This device can be a disk file, a network channel, a memory location, or any other object that supports reading and writing to it in a linear manner.
  • 5. There are two types of streams: Output:  Output streams are used when data is written to some external destination.  External destination: a physical disk file, a network location, a printer, or another program. Input:  Input streams are used to read data into memory or variables that your program can access.  An input stream can come from almost any source
  • 6. THE CLASSES FOR INPUT &OUTPUT • The System.IO namespace contains almost all of the classes for read & write operation. • few classes are contained in System.IO. CLASS File Directory Path StreamReader StreamWriter
  • 7. The File and Directory Classes • The File and Directory utility classes expose many static methods for manipulating. • File classes have some method METHOD DESCRIPTION Copy() Copies a file from a source location to a target location. Create() Creates a file in the specified path. Delete() Deletes a file. Open() Returns a FileStream object at the specified path. Move() Moves a specified file to a new location. You can specify a different name for the file in the new location.
  • 8. Directory classes have some method Path Names and Relative Paths:  When specifying a path name in .NET code, you can use either absolute or relative path names. • An absolute path name explicitly specifies a file or directory from a known location — such as the C: drive. • C:WorkLogFile.txt — this path defines exactly where the file is, with no ambiguity. Method Description CreateDirectory() Creates a directory with the specified path. Delete() Deletes the specified directory and all the files within it.
  • 9.  Relative path names are relative to a starting location.  By using relative path names, no drive or known location needs to be specified. • The current working directory was the starting point, which is the default behavior for relative path names. • For example, if your application is running in the C:DevelopmentFileDemo directory and uses the relative path LogFile.txt, the file references would be C:DevelopmentFileDemoLogFile.txt.
  • 10. The StreamWriter Object • The StreamWriter class enables you to write characters and strings to a file. • The StreamWriter class handles the writing to the FileStream object. FileStream aFile = new FileStream("Log.txt", FileMode.CreateNew); StreamWriter sw = new StreamWriter(aFile); • A StreamWriter object can also be created directly from a file: StreamWriter sw = new StreamWriter("Log.txt", true);
  • 11. • If this is set to false, then a new file is created or the existing file is truncated and then opened. • If it is set to true, then the file is opened and the data is retained. If there is no file, then a new one is created.
  • 12. The StreamReader Object Input streams are used to read data from an external source. StreamReader objects are created in much the same way as StreamWriter objects.
  • 13. The StreamReader Object Input streams are used to read data from an external source. StreamReader objects are created in much the same way as StreamWriter objects.
  • 14. • StreamReader objects are created in much the same way as StreamWriter objects. • FileStream aFile = new FileStream("Log.txt", FileMode.Open); • StreamReader sr = new StreamReader(aFile); • The StreamReader class can be created directly from a string containing the path to a particular file: • StreamReader sr = new StreamReader("Log.txt");
  • 15. Summary • File program concept. • Several property of System.IO Namespace. • Stream concept • StreamWriter & StreamReader.