4

I am making a windows 8.1 store app. I want to set a default directory to cashe some images and am using this code to do it:

using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace YouMaps.Tiles
{
class TileLoader
{
    public const string defaultCasheName = "YouMapsTileCashe";
    public static string defaultCasheDirectory = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.CommonApplicationData), "YouMaps");

I am getting an error that System.Environment does not contain definitions for GetFolderPath and SpecialFolder. I F12'ed over Environment and sure enough, this was all that was in there

#region Assembly System.Runtime.Extensions.dll, v4.0.0.0
// C:\Program Files (x86)\Reference Assemblies\Microsoft\Framework\.NETCore\v4.5.1\System.Runtime.Extensions.dll
#endregion
using System.Security;

namespace System
{
public static class Environment
 {

    public static int CurrentManagedThreadId { get; }
    public static bool HasShutdownStarted { get; }
    public static string NewLine { get; }
    public static int ProcessorCount { get; }
    public static int TickCount { get; }
    public static void FailFast(string message);        
    public static void FailFast(string message, Exception exception);
 }
}

However, when I look on with windows MSDN it seems to show that even windows 8.1 should have access to the full range of definitions. I have searched using Google and just inside of stack overflow to see if anyone else has had this problem but I have found nothing even remotely like it. So, the question-Can anyone tell me why my Environment is "missing" the 90% of its definitions and secondly, how do I fix it?

oh, and here are my references:

.NET for Windows Store apps
Bing Maps for C#, C++, or Visual Basic
Microsoft Visual C++ 2013 Runtime Package for Windows
SharpKml
Windows

Thanks for reading my question and providing help. This is the first question I have ever asked so if I broke some rules etiquette or failed to include some pertinent information let me know.

RvrTex
  • 81
  • 8

2 Answers2

3

For Windows Store apps, you should use the local or roaming folder to cache application-specific data:

Windows.Storage.ApplicationData.Current.LocalFolder or Windows.Storage.ApplicationData.Current.RoamingFolder

http://msdn.microsoft.com/en-us/library/windows/apps/windows.storage.applicationdata.aspx

There is also Windows.Storage.ApplicationData.Current.TemporaryFolder for temporary data.

Michael S. Scherotter
  • 10,715
  • 3
  • 34
  • 57
0

Try this:

Environment.GetEnvironmentVariable("LocalAppData");

p.s. tested on windows

Paul Roub
  • 36,322
  • 27
  • 84
  • 93
parismiguel
  • 586
  • 6
  • 16