IsolatedStorageFileStream has an unexpected result on ms.net

Expected is: 56
Result of FileStream is: 56
Result of IsolatedStorageFileStream is: 55
Press any key to continue . . .

        private static string TestFileStream(bool isIsolatedStorageFileStream)
        {
            FileStream r;
            FileStream w;
            if (isIsolatedStorageFileStream)
            {
                r = new IsolatedStorageFileStream("AA", FileMode.OpenOrCreate, FileAccess.ReadWrite, 
FileShare.ReadWrite);
                w = new IsolatedStorageFileStream("AA", FileMode.OpenOrCreate, FileAccess.ReadWrite, 
FileShare.ReadWrite);
            }
            else
            {
                r = new FileStream("AA", FileMode.OpenOrCreate, FileAccess.Read, FileShare.ReadWrite);
                w = new FileStream("AA", FileMode.OpenOrCreate, FileAccess.ReadWrite, FileShare.Read);
            }
            string result = "";

            w.Position = 0;
            w.WriteByte(5);
            w.WriteByte(5);
            w.Flush();

            r.Position = 0;
            result += r.ReadByte();

            w.Position = 0;
            w.WriteByte(6);
            w.WriteByte(6);
            w.Flush();
                        
            r.Position = 1;
            result += r.ReadByte();

            return result;
        }

        static void Main(string[] args)
        {
            Console.WriteLine("Expected is: 56");
            Console.WriteLine("Result of FileStream is: " + TestFileStream(false));
            Console.WriteLine("Result of IsolatedStorageFileStream is: " + TestFileStream(true));
         }

Last edited Apr 25, 2014 at 3:13 PM by iboxdb, version 3

Comments

No comments yet.