special folders

This commit is contained in:
2017-03-09 22:20:19 +01:00
parent 11e5bf3a38
commit e05716344b
2 changed files with 16 additions and 9 deletions

View File

@ -6,6 +6,7 @@ using System.Net;
using System.Runtime.Serialization.Json;
using System.Text;
using ZicMoove.Model.Auth.Account;
using System.IO;
namespace ZicMoove.Droid
{
@ -13,13 +14,23 @@ namespace ZicMoove.Droid
public static class YavscHelpers
{
public static void SetRegId(this User user, string regId)
public static string GetSpecialFolder(this string specialPath)
{
if (user.YavscTokens == null)
if (specialPath == null)
throw new InvalidOperationException();
var appData =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
string imagesFolder = System.IO.Path.Combine(appData, specialPath);
DirectoryInfo di = new DirectoryInfo(imagesFolder);
// FIXME Create this folder at app startup
if (!di.Exists) di.Create();
return imagesFolder;
}
public static string GetTmpDir ()
{
return GetSpecialFolder("tmp");
}
}
}

View File

@ -505,11 +505,7 @@ namespace ZicMoove.Droid
get
{
if (imagesFolder != null) return imagesFolder;
var appData =
System.Environment.GetFolderPath(System.Environment.SpecialFolder.ApplicationData);
imagesFolder = System.IO.Path.Combine(appData, Constants.ImagePath);
DirectoryInfo di = new DirectoryInfo(imagesFolder);
if (!di.Exists) di.Create();
imagesFolder = Constants.ImagePath.GetSpecialFolder();
return imagesFolder;
}
}