- Trending Categories
- Data Structure
- Networking
- RDBMS
- Operating System
- Java
- MS Excel
- iOS
- HTML
- CSS
- Android
- Python
- C Programming
- C++
- C#
- MongoDB
- MySQL
- Javascript
- PHP
- Physics
- Chemistry
- Biology
- Mathematics
- English
- Economics
- Psychology
- Social Studies
- Fashion Studies
- Legal Studies
- Selected Reading
- UPSC IAS Exams Notes
- Developer's Best Practices
- Questions and Answers
- Effective Resume Writing
- HR Interview Questions
- Computer Glossary
- Who is Who
How to use C# FileStream class?
A stream for file operations such as read and write is provided by the FileStream class.
Create an object like this
FileStream fstream = new FileStream("d:\
ew.txt", FileMode.OpenOrCreate);
Above we have used FileMode.OpenOrCreate so that the file or opened or created if it does not already exist.
The following is n example showing how to use the FileStream class in C# −
using System; using System.IO; public class Demo { public static void Main(string[] args) { FileStream fstream = new FileStream("d:\
ew.txt", FileMode.OpenOrCreate); // write into the file fstream.WriteByte(90); // close the file fstream.Close(); } }
Advertisements