I have a code like this:
<code>string filePath = Path.Combine(FileSystem.AppDataDirectory, "test.jpg");
if (File.Exists(filePath))
{
try
{
File.Delete(filePath);
}
catch (Exception ex) {
Debug.WriteLine("Exception!");
}
}
else
{
Debug.WriteLine("File not exists!");
}
if(File.Exists(filePath))
{
Debug.WriteLine("File not deleted!");
}
// Output: File not deleted!
</code>
<code>string filePath = Path.Combine(FileSystem.AppDataDirectory, "test.jpg");
if (File.Exists(filePath))
{
try
{
File.Delete(filePath);
}
catch (Exception ex) {
Debug.WriteLine("Exception!");
}
}
else
{
Debug.WriteLine("File not exists!");
}
if(File.Exists(filePath))
{
Debug.WriteLine("File not deleted!");
}
// Output: File not deleted!
</code>
string filePath = Path.Combine(FileSystem.AppDataDirectory, "test.jpg");
if (File.Exists(filePath))
{
try
{
File.Delete(filePath);
}
catch (Exception ex) {
Debug.WriteLine("Exception!");
}
}
else
{
Debug.WriteLine("File not exists!");
}
if(File.Exists(filePath))
{
Debug.WriteLine("File not deleted!");
}
// Output: File not deleted!
I am writing an application for Android. I am trying to delete a file in the AppDataDirectory folder but I cannot delete it. I also do not receive any exception messages. I cannot understand this situation. (Although the AppDataDirectory folder does not require write permission, I have added the necessary permissions. Also, such a problem does not occur in the Windows application and the file is deleted). Friends, can you help me with this issue?