Skip to content

CreationCollisionOption.ReplaceExisting is treated as CreationCollisionOption.OpenIfExists #1067

Closed

Description

@zipswich
 //The following code shows CreationCollisionOption.ReplaceExisting is treated as CreationCollisionOption.OpenIfExists
            StorageFile sfFoo = await ApplicationData.Current.LocalFolder.CreateFileAsync("foo", CreationCollisionOption.ReplaceExisting);
            using (StreamWriter dr = new StreamWriter(await sfFoo.OpenStreamForWriteAsync()))
            {
                await dr.WriteAsync("this is foo + foo");
                await dr.FlushAsync();
                dr.Close(); //Supposed to be redundant
            }
            StorageFile sfFoo2 = await ApplicationData.Current.LocalFolder.CreateFileAsync("foo", CreationCollisionOption.ReplaceExisting);
            using (StreamWriter dr = new StreamWriter(await sfFoo.OpenStreamForWriteAsync()))
            {
                await dr.WriteAsync("this is abc");
                await dr.FlushAsync();
                dr.Close(); //Supposed to be redundant
            }

            StorageFile sfFooRead = await ApplicationData.Current.LocalFolder.GetFileAsync("foo");
            using (FileStream stream = File.OpenRead(sfFooRead.Path))
            using (StreamReader sr = new StreamReader(stream))
            {
                {
                    //The following outputs: "this is abc + foo"
                    //It is supposed to be: "this is abc"
                    Console.WriteLine(sr.ReadToEnd());
                }
            }

Environment

  • OS: iOS
  • Version 12
  • Device: Simulator

Repro:
https://github.com/zipswich/UnoDebug

Activity

  1. added
    platform/ios 🍎
    kind/bug
    on Jun 19, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

Labels

kind/bugplatform/ios 🍎

Type

No type

Projects

No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions