mirror of
https://github.com/ClemensFischer/XAML-Map-Control.git
synced 2025-12-06 07:12:04 +01:00
Add FilePath helper class
This commit is contained in:
parent
7d1d7dbe23
commit
421f323116
21
MapControl/Shared/FilePath.cs
Normal file
21
MapControl/Shared/FilePath.cs
Normal file
|
|
@ -0,0 +1,21 @@
|
|||
// XAML Map Control - https://github.com/ClemensFischer/XAML-Map-Control
|
||||
// © 2022 Clemens Fischer
|
||||
// Licensed under the Microsoft Public License (Ms-PL)
|
||||
|
||||
using System;
|
||||
using System.IO;
|
||||
|
||||
namespace MapControl
|
||||
{
|
||||
public static class FilePath
|
||||
{
|
||||
public static string GetFullPath(string path)
|
||||
{
|
||||
#if WINUI
|
||||
return Path.GetFullPath(path, AppDomain.CurrentDomain.BaseDirectory);
|
||||
#else
|
||||
return Path.GetFullPath(path);
|
||||
#endif
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -174,7 +174,7 @@ namespace MapControl
|
|||
|
||||
private static async Task<IEnumerable<ImageOverlay>> ReadGroundOverlaysFromFileAsync(string docFilePath)
|
||||
{
|
||||
docFilePath = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, docFilePath);
|
||||
docFilePath = FilePath.GetFullPath(docFilePath);
|
||||
|
||||
var docUri = new Uri(docFilePath);
|
||||
|
||||
|
|
|
|||
|
|
@ -71,6 +71,9 @@
|
|||
<Compile Include="..\Shared\EquirectangularProjection.cs">
|
||||
<Link>EquirectangularProjection.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\FilePath.cs">
|
||||
<Link>FilePath.cs</Link>
|
||||
</Compile>
|
||||
<Compile Include="..\Shared\GeoImage.cs">
|
||||
<Link>GeoImage.cs</Link>
|
||||
</Compile>
|
||||
|
|
|
|||
|
|
@ -20,8 +20,7 @@ namespace MapControl
|
|||
{
|
||||
public static async Task<Tuple<BitmapSource, Matrix>> ReadGeoTiff(string sourcePath)
|
||||
{
|
||||
var file = await StorageFile.GetFileFromPathAsync(
|
||||
Path.Combine(AppDomain.CurrentDomain.BaseDirectory, sourcePath));
|
||||
var file = await StorageFile.GetFileFromPathAsync(FilePath.GetFullPath(sourcePath));
|
||||
|
||||
using (var stream = await file.OpenReadAsync())
|
||||
{
|
||||
|
|
|
|||
|
|
@ -50,7 +50,7 @@ namespace MapControl
|
|||
{
|
||||
ImageSource image = null;
|
||||
|
||||
path = Path.Combine(AppDomain.CurrentDomain.BaseDirectory, path);
|
||||
path = FilePath.GetFullPath(path);
|
||||
|
||||
if (File.Exists(path))
|
||||
{
|
||||
|
|
|
|||
Loading…
Reference in a new issue