Essentials: [Enhancement] Add Temporary Directory to File System Helpers

Created on 22 Mar 2020  路  4Comments  路  Source: xamarin/Essentials

Summary

Add Temporary Directory to access each platform's temporary folder.

API Changes

We could add a new TemporaryDirectory static property to FileSystem class

public static string TemporaryDirectory => PlatformTemporaryDirectory

UWP

ApplicationData.Current.TemporaryFolder.Path

iOS

Path.Combine(Environment.GetFolderPath (Environment.SpecialFolder.MyDocuments), "..", "tmp")

Android

Android.OS.Environment.DownloadCacheDirectory

Intended Use Case

The Cache directory is a great place for files that are easily recreated when lost but currently we don't have a way of accessing a directory for temporary files.

feature-request

All 4 comments

Why is System.IO.Path.GetTempPath() not sufficient?

Why is System.IO.Path.GetTempPath() not sufficient?

I had reservations if all of the Platforms implemented that method as the docs is not clear if it will return the temp directory that will be accessible from the app. I also read somewhere that in iOS, this method is missing?

In Xamarin.iOS
Method System.IO.Path.GetTempPath() is missing.
source

I researched more on this issue and I have found that System.IO.Path.GetTempPath() really does the job. Will be closing this issue now. Thanks!

Here is a good breakdown of where all standard system.io paths go: https://github.com/dotnet-ad/Standard.SpecialFolders

Was this page helpful?
0 / 5 - 0 ratings