You need a single stream, opened for both reading and writing.
FileStream fileStream = new FileStream(
@"c:\words.txt", FileMode.OpenOrCreate,
FileAccess.ReadWrite, FileShare.None);
More Related Contents:
- Is there a way to check if a file is in use?
- Parsing CSV files in C#, with header
- What’s the fastest way to read a text file line-by-line?
- Easiest way to read from and write to files
- FileSystemWatcher vs polling to watch for file changes
- How do I create an Excel (.XLS and .XLSX) file in C# without installing Microsoft Office?
- Validate image from file in C#
- How to read an entire file to a string using C#?
- Reading a file used by another process [duplicate]
- The input is not a valid Base-64 string as it contains a non-base 64 character
- C# FileStream : Optimal buffer size for writing large files?
- How to read the data in a wav file to an array
- Open file ReadOnly
- Extremely Large Single-Line File Parse
- Encode a FileStream to base64 with c#
- Why does BinaryWriter prepend gibberish to the start of a stream? How do you avoid it?
- Sharing violation IOException while reading and writing to file C#
- System.IO.FileStream FileAccess vs FileShare
- Can I simply ‘read’ a file that is in use?
- Is there a faster way than this to find all the files in a directory and all sub directories?
- can I check if a file exists at a URL?
- Can you keep a StreamReader from disposing the underlying stream?
- C#: Prepending to beginning of a file
- File Copy with Progress Bar
- Wait for file to be freed by process
- Unit Testing File I/O
- Can .NET load and parse a properties file equivalent to Java Properties class?
- Write to a file from multiple threads asynchronously c#
- How to properly read and write a file using Windows.Storage on Windows Phone 8
- Access to the path denied error in C#