Skip to content
This repository has been archived by the owner on Nov 2, 2021. It is now read-only.

Commit

Permalink
-Added Base Folder Redirection for NetCore, you can now use the Syste…
Browse files Browse the repository at this point in the history
…m's AppData folder, or a local folder in your Binaries folder.

-Made NETCore a .NET Core 2.0 Library.

-Added missing Pictures Enum.
  • Loading branch information
WilliamABradley committed Oct 17, 2017
1 parent aebfeaf commit 6b1e5ac
Show file tree
Hide file tree
Showing 4 changed files with 36 additions and 2 deletions.
1 change: 1 addition & 0 deletions PlatformBindings-Core/Enums/PathRoot.cs
Original file line number Diff line number Diff line change
Expand Up @@ -9,6 +9,7 @@ public enum PathRoot
Application,
Downloads,
Videos,
Pictures,
Documents,
Music
}
Expand Down
2 changes: 2 additions & 0 deletions PlatformBindings-NETCore/NETCoreServices.cs
Original file line number Diff line number Diff line change
Expand Up @@ -11,6 +11,8 @@ public NETCoreServices() : base(true)
IO = new CoreIOBindings();
}

public static bool UseGlobalAppData = true;

public override Version GetAppVersion()
{
throw new NotImplementedException();
Expand Down
2 changes: 1 addition & 1 deletion PlatformBindings-NETCore/PlatformBindings-NETCore.csproj
Original file line number Diff line number Diff line change
@@ -1,7 +1,7 @@
<Project Sdk="Microsoft.NET.Sdk">

<PropertyGroup>
<TargetFramework>netcoreapp1.1</TargetFramework>
<TargetFramework>netcoreapp2.0</TargetFramework>
<RootNamespace>PlatformBindings</RootNamespace>
<Title>PlatformBindings-NETCore</Title>
<Description>.NET Core Head for the .NET Platform Bindings Framework</Description>
Expand Down
33 changes: 32 additions & 1 deletion PlatformBindings-NETCore/Services/CoreIOBindings.cs
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
using PlatformBindings.Models.FileSystem;
using PlatformBindings.Models.Settings;
using System.Reflection;
using PlatformBindings.Common;

namespace PlatformBindings.Services
{
Expand Down Expand Up @@ -70,8 +71,38 @@ public override FolderContainerBase GetBaseFolder(PathRoot Root)
{
switch (Root)
{
default:
case PathRoot.LocalAppStorage:
case PathRoot.RoamingAppStorage:
case PathRoot.AppStorageNoBackup:
if (NETCoreServices.UseGlobalAppData)
{
var folder = Root == PathRoot.LocalAppStorage ? Environment.SpecialFolder.LocalApplicationData : Environment.SpecialFolder.ApplicationData;
return new CoreFolderContainer(Environment.GetFolderPath(folder));
}
else return new CoreFolderContainer(PlatformBindingHelpers.ResolvePath(new FolderPath(PathRoot.Application, "AppData")));

case PathRoot.Documents:
return new CoreFolderContainer(Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));

case PathRoot.Pictures:
return new CoreFolderContainer(Environment.GetFolderPath(Environment.SpecialFolder.MyPictures));

case PathRoot.Videos:
return new CoreFolderContainer(Environment.GetFolderPath(Environment.SpecialFolder.MyVideos));

case PathRoot.Music:
return new CoreFolderContainer(Environment.GetFolderPath(Environment.SpecialFolder.MyMusic));

case PathRoot.Downloads:
var path = Path.GetDirectoryName(Environment.GetFolderPath(Environment.SpecialFolder.Personal));
path = Path.Combine(path, "Downloads");
return new CoreFolderContainer(path);

case PathRoot.Application:
return new CoreFolderContainer(Path.GetDirectoryName(Assembly.GetEntryAssembly().Location));

default:
return null;
}
}

Expand Down

0 comments on commit 6b1e5ac

Please sign in to comment.