Quantcast
Channel: User Liyun Zhang - MSFT - Stack Overflow
Viewing all articles
Browse latest Browse all 444

Answer by Liyun Zhang - MSFT for File Delete Not Working on .NET MAUI (for Android Platform)

$
0
0

First of, the Path.Combine will not create the file if it's not existed on the android. So I used the FileStream to create it.

string filePath = Path.Combine(FileSystem.AppDataDirectory, "test.jpg");using (FileStream fileStream = new FileStream(filePath, FileMode.OpenOrCreate)){}

And then, the File.Delete(filePath) work well in my project. The output in my project:

// Output: File Exist!

And I have used the Device File Explorer in the Android Studio to check the result: The file will be deleted after File.Delete(filePath) excuted.

The environment I used:

  • Visual Studio 17.11.0 Preview 2.1
  • .Net 8.0
  • Test on both Android 10 emulator and XiaoMi physical device with Android 14.0

Viewing all articles
Browse latest Browse all 444

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>