Communities for your favorite technologies. Explore all Collectives
Stack Overflow for Teams is now called Stack Internal. Bring the best of human thought and AI automation together at your work.
Bring the best of human thought and AI automation together at your work. Learn more
Find centralized, trusted content and collaborate around the technologies you use most.
Stack Internal
Knowledge at work
Bring the best of human thought and AI automation together at your work.
How can I write to a file which is used by another process in C#?
I am able to read the file using FileShare.ReadWrite, but it only works for FileAccess.Read. Does anyone have a solution?
FileShare.ReadWrite
FileAccess.Read
File.Create
If the other process has write-locked the file, then there's not much you can do, unless you don't mind closing the other process's handle or killing it.
Add a comment
You should read the file contents to a separate Stream and then the file is released.
Required, but never shown
By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.
Start asking to get answers
Find the answer to your question by asking.
Explore related questions
See similar questions with these tags.
File.Create?