• Status: Solved
  • Priority: Medium
  • Security: Public
  • Views: 5046
  • Last Modified:

Create File Lock

I need to test a program of our that is having issues with file locks when the load on the system is high.  I need to simualte a file lock that will not give me access to the file.  Is there a quick and easy way to make a file lock exclusive in C#?
1 Solution
You can use File.Open Method (String, FileMode, FileAccess, FileShare) to open file in Open mode, Read access and None sharing. All time FileStream instance returned by this method exists and not disposed, file is locked.
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

Join & Write a Comment

Featured Post

Cloud Class® Course: Ruby Fundamentals

This course will introduce you to Ruby, as well as teach you about classes, methods, variables, data structures, loops, enumerable methods, and finishing touches.

Tackle projects and never again get stuck behind a technical roadblock.
Join Now