Not showing Created folder in My App directory MAUI

35 views Asked by At
string mainDir = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory,"logs");


if (!Directory.Exists(mainDir))
{
  Directory.CreateDirectory(mainDir);
}

I am trying to create folder to save log txt file in my project application directory i am writing below code but its not showing any file or folder

mainDir return this below path " /data/user/0/com.xxx.xxx/files/logs" when i see the applications directory it is having only cache directory not creating logs directory. can you help anything wrong.

1

There are 1 answers

0
Liyun Zhang - MSFT On

Actually, you have created the directory successfully. It didn't show because the directory with path Path.Combine(FileSystem.AppDataDirectory, filename) can't be found by the Android System File Manager.

But you can find it with the Android Studio's Device File Explorer. In addition, you can try to check if the directory is created or not by the following code:

string mainDir = System.IO.Path.Combine(FileSystem.Current.AppDataDirectory,"logs");
var check = Directory.Exists(mainDir);