Bugzilla – Bug 316914
Locking on portions of file fails.
Last modified: 2007-09-15 21:24:46 UTC
---- Reported by miguel@ximian.com 2005-01-18 01:10:53 MST ---- .NET implements file-locking behavior. from our test suite: using System; using System.IO; class X { static void Main () { string path = "TestLock"; File.Delete (path); FileStream stream = new FileStream (path, FileMode.CreateNew, FileAccess.ReadWrite); stream.Write (new Byte [] {0,1,2,3,4,5,6,7,8,9,10}, 0, 10); stream.Close (); stream = new FileStream (path, FileMode.Open, FileAccess.ReadWrite); stream.Lock (0, 5); FileStream stream2 = new FileStream (path , FileMode.Open, FileAccess.Read, FileShare.ReadWrite); byte [] bytes = new byte [5]; try { stream2.Read (bytes, 0, 5); Console.WriteLine ("The read should have failed for the portion locked"); } catch (Exception e) { Console.WriteLine ("Ok"); } } } This program should print "ok" ---- Additional Comments From dick@ximian.com 2005-01-18 06:59:21 MST ---- *** This bug has been marked as a duplicate of https://bugzilla.novell.com/show_bug.cgi?id=MONO71292 *** Unknown operating system unknown. Setting to default OS "Other". This bug was marked DUPLICATE in the database it was moved from. Changing resolution to "MOVED"