Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

[Problem/Bug]: Webview2 FileIO.writeTextAsync throws "The system cannot find the file specified 0x80070002" when writing on the same file multiple times asynchronous #4745

Open
josephsobhy opened this issue Aug 15, 2024 · 1 comment
Assignees
Labels
bug Something isn't working tracked We are tracking this work internally.

Comments

@josephsobhy
Copy link

josephsobhy commented Aug 15, 2024

What happened?

Using the WinRT API Windows.Storage.FileIO.writeTextAsync from java script in webview2 throws "The system cannot find the file specified 0x80070002" even that the file exists.

Some times it throws "The process cannot access the file because it is being used by another process. (0x80070020)" which is expected but the 0x80070002 is not correct.

Also tested the same behaviour is webview1 and it never throws anything!.

let root = Windows.Storage.ApplicationData.current.localFolder;

root.createFileAsync("fileName", Windows.Storage.CreationCollisionOption.openIfExists).then((file) => {
       Windows.Storage.FileIO.writeTextAsync(file, "data 1")
       console.log('data 1 saved');
   })

  root.createFileAsync("fileName", Windows.Storage.CreationCollisionOption.openIfExists).then((file) => {
       Windows.Storage.FileIO.writeTextAsync(file, "data 2")
       console.log('data 2 saved');
   })

writeText issue

Importance

Important. My app's user experience is significantly compromised.

Runtime Channel

Stable release (WebView2 Runtime)

Runtime Version

No response

SDK Version

No response

Framework

WinUI2/UWP

Operating System

Windows 10, Windows 11

OS Version

No response

Repro steps

let root = Windows.Storage.ApplicationData.current.localFolder;

root.createFileAsync("fileName", Windows.Storage.CreationCollisionOption.openIfExists).then((file) => {
       Windows.Storage.FileIO.writeTextAsync(file, "data 1")
       console.log('data 1 saved');
   })

  root.createFileAsync("fileName", Windows.Storage.CreationCollisionOption.openIfExists).then((file) => {
       Windows.Storage.FileIO.writeTextAsync(file, "data 2")
       console.log('data 2 saved');
   })

Repros in Edge Browser

No, issue does not reproduce in the corresponding Edge version

Regression

Don't know

Last working version (if regression)

No response

AB#54034963

@josephsobhy josephsobhy added the bug Something isn't working label Aug 15, 2024
@champnic
Copy link
Member

Thanks for letting us know about this issue @josephsobhy - I've added it to our internal tracking.

@champnic champnic added the tracked We are tracking this work internally. label Sep 20, 2024
@champnic champnic self-assigned this Sep 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working tracked We are tracking this work internally.
Projects
None yet
Development

No branches or pull requests

2 participants