0

I had a webservice that reads .txt files using StreamReader and sends back responses to the user. If multiple people call my webservice, will the .txt files be "locked" and thus only be able to handle processing one request at a time?

Thanks.

user1506863
  • 55
  • 1
  • 6

2 Answers2

3

Files are not locked during reads using streamreader.

Freeman
  • 5,691
  • 3
  • 29
  • 41
0

I think this depends. Are any changes being made to the text file? If not, then the file should not be locked, because once it is opened, it should be read into the stream using a stremreader object, and then closed. Refer to

How do I open an already opened file with a .net StreamReader?

and

http://msdn.microsoft.com/en-us/library/db5x7c0d.aspx

This code creates a StreamReader that points to MyFile.txt through a call to File.OpenText. StreamReader.ReadLine returns each line as a string. When there are no more characters to read, a message is displayed to that effect, and the stream is closed.

Community
  • 1
  • 1
GrayFox374
  • 1,742
  • 9
  • 13