Version 0.5.0 - tested with 32-bit and 64-bit version of Framework
This commit is contained in:
parent
c11828a7d5
commit
d27b949849
@ -13,34 +13,48 @@ Global
|
||||
GlobalSection(SolutionConfigurationPlatforms) = preSolution
|
||||
Debug|Any CPU = Debug|Any CPU
|
||||
Debug|x64 = Debug|x64
|
||||
Debug|x86 = Debug|x86
|
||||
Release|Any CPU = Release|Any CPU
|
||||
Release|x64 = Release|x64
|
||||
Release|x86 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(ProjectConfigurationPlatforms) = postSolution
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|x64.Build.0 = Release|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{4127F279-9FD5-4C37-B904-242C124C1A07}.Release|x86.Build.0 = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|x64.ActiveCfg = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|x64.Build.0 = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|x86.ActiveCfg = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Debug|x86.Build.0 = Debug|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|x64.ActiveCfg = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|x64.Build.0 = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|x86.ActiveCfg = Release|Any CPU
|
||||
{427E5F76-8418-4EA3-9AA3-C1DBFDE0478F}.Release|x86.Build.0 = Release|Any CPU
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|Any CPU.ActiveCfg = Debug|Any CPU
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|Any CPU.Build.0 = Debug|Any CPU
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|x64.ActiveCfg = Debug|x64
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|x64.Build.0 = Debug|x64
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|x86.ActiveCfg = Debug|x86
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Debug|x86.Build.0 = Debug|x86
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|Any CPU.ActiveCfg = Release|Any CPU
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|Any CPU.Build.0 = Release|Any CPU
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|x64.ActiveCfg = Release|x64
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|x64.Build.0 = Release|x64
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|x86.ActiveCfg = Release|x86
|
||||
{0FD91168-D8F5-4776-8D91-CB9B9C55AA1B}.Release|x86.Build.0 = Release|x86
|
||||
EndGlobalSection
|
||||
GlobalSection(SolutionProperties) = preSolution
|
||||
HideSolutionNode = FALSE
|
||||
|
@ -15,6 +15,12 @@
|
||||
|
||||
<ItemGroup>
|
||||
<Content Include="runtimes\**" PackagePath="runtimes" Visible="false" />
|
||||
<Content Include="nfd.dll">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
<Content Include="nfd_x86.dll">
|
||||
<CopyToPublishDirectory>PreserveNewest</CopyToPublishDirectory>
|
||||
</Content>
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
|
@ -1,6 +1,7 @@
|
||||
using System;
|
||||
using System.Collections.Generic;
|
||||
using System.Diagnostics;
|
||||
using System.Runtime.InteropServices;
|
||||
using System.Text;
|
||||
using NativeFileDialogSharp.Native;
|
||||
|
||||
@ -10,6 +11,32 @@ namespace NativeFileDialogSharp
|
||||
{
|
||||
private static readonly Encoder utf8encoder = Encoding.UTF8.GetEncoder();
|
||||
|
||||
private static readonly bool need32bit = Is32BitWindowsOnNetFramework();
|
||||
|
||||
private static bool Is32BitWindowsOnNetFramework()
|
||||
{
|
||||
try
|
||||
{
|
||||
// we call a function that does nothing just to test if we can load it properly
|
||||
NativeFileDialogSharp.Native.NativeFunctions.NFD_Dummy();
|
||||
return false;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// a call to a default library failed, let's attempt the other one
|
||||
try
|
||||
{
|
||||
NativeFileDialogSharp.Native.NativeFunctions32.NFD_Dummy();
|
||||
return true;
|
||||
}
|
||||
catch
|
||||
{
|
||||
// both of them failed so we may as well default to the default one for predictability
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private static unsafe byte[] ToUtf8(string s)
|
||||
{
|
||||
var byteCount = Encoding.UTF8.GetByteCount(s);
|
||||
@ -50,7 +77,10 @@ namespace NativeFileDialogSharp
|
||||
{
|
||||
string path = null;
|
||||
string errorMessage = null;
|
||||
var result = NativeFunctions.NFD_OpenDialog(filterListNts, defaultPathNts, out IntPtr outPathIntPtr);
|
||||
IntPtr outPathIntPtr;
|
||||
var result = need32bit
|
||||
? NativeFunctions32.NFD_OpenDialog(filterListNts, defaultPathNts, out outPathIntPtr)
|
||||
: NativeFunctions.NFD_OpenDialog(filterListNts, defaultPathNts, out outPathIntPtr);
|
||||
if (result == nfdresult_t.NFD_ERROR)
|
||||
{
|
||||
errorMessage = FromUtf8(NativeFunctions.NFD_GetError());
|
||||
@ -73,7 +103,10 @@ namespace NativeFileDialogSharp
|
||||
{
|
||||
string path = null;
|
||||
string errorMessage = null;
|
||||
var result = NativeFunctions.NFD_SaveDialog(filterListNts, defaultPathNts, out IntPtr outPathIntPtr);
|
||||
IntPtr outPathIntPtr;
|
||||
var result = need32bit
|
||||
? NativeFunctions32.NFD_SaveDialog(filterListNts, defaultPathNts, out outPathIntPtr)
|
||||
: NativeFunctions.NFD_SaveDialog(filterListNts, defaultPathNts, out outPathIntPtr);
|
||||
if (result == nfdresult_t.NFD_ERROR)
|
||||
{
|
||||
errorMessage = FromUtf8(NativeFunctions.NFD_GetError());
|
||||
@ -95,7 +128,10 @@ namespace NativeFileDialogSharp
|
||||
{
|
||||
string path = null;
|
||||
string errorMessage = null;
|
||||
var result = NativeFunctions.NFD_PickFolder(defaultPathNts, out IntPtr outPathIntPtr);
|
||||
IntPtr outPathIntPtr;
|
||||
var result = need32bit
|
||||
? NativeFunctions32.NFD_PickFolder(defaultPathNts, out outPathIntPtr)
|
||||
: NativeFunctions.NFD_PickFolder(defaultPathNts, out outPathIntPtr);
|
||||
if (result == nfdresult_t.NFD_ERROR)
|
||||
{
|
||||
errorMessage = FromUtf8(NativeFunctions.NFD_GetError());
|
||||
@ -119,7 +155,9 @@ namespace NativeFileDialogSharp
|
||||
List<string> paths = null;
|
||||
string errorMessage = null;
|
||||
nfdpathset_t pathSet;
|
||||
var result = NativeFunctions.NFD_OpenDialogMultiple(filterListNts, defaultPathNts, &pathSet);
|
||||
var result = need32bit
|
||||
? NativeFunctions32.NFD_OpenDialogMultiple(filterListNts, defaultPathNts, &pathSet)
|
||||
: NativeFunctions.NFD_OpenDialogMultiple(filterListNts, defaultPathNts, &pathSet);
|
||||
if (result == nfdresult_t.NFD_ERROR)
|
||||
{
|
||||
errorMessage = FromUtf8(NativeFunctions.NFD_GetError());
|
||||
|
BIN
NativeFileDialogSharp/nfd.dll
Normal file
BIN
NativeFileDialogSharp/nfd.dll
Normal file
Binary file not shown.
BIN
NativeFileDialogSharp/nfd_x86.dll
Normal file
BIN
NativeFileDialogSharp/nfd_x86.dll
Normal file
Binary file not shown.
@ -53,9 +53,29 @@
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Debug|x86'">
|
||||
<DebugSymbols>true</DebugSymbols>
|
||||
<OutputPath>bin\x86\Debug\</OutputPath>
|
||||
<DefineConstants>DEBUG;TRACE</DefineConstants>
|
||||
<DebugType>full</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<PropertyGroup Condition="'$(Configuration)|$(Platform)' == 'Release|x86'">
|
||||
<OutputPath>bin\x86\Release\</OutputPath>
|
||||
<DefineConstants>TRACE</DefineConstants>
|
||||
<Optimize>true</Optimize>
|
||||
<DebugType>pdbonly</DebugType>
|
||||
<PlatformTarget>x86</PlatformTarget>
|
||||
<LangVersion>7.3</LangVersion>
|
||||
<ErrorReport>prompt</ErrorReport>
|
||||
<Prefer32Bit>true</Prefer32Bit>
|
||||
</PropertyGroup>
|
||||
<ItemGroup>
|
||||
<Reference Include="NativeFileDialogSharp, Version=1.0.0.0, Culture=neutral, processorArchitecture=MSIL">
|
||||
<HintPath>..\packages\NativeFileDialogSharp.0.4.4\lib\net461\NativeFileDialogSharp.dll</HintPath>
|
||||
<HintPath>..\packages\NativeFileDialogSharp.0.5.0\lib\netstandard2.0\NativeFileDialogSharp.dll</HintPath>
|
||||
</Reference>
|
||||
<Reference Include="System" />
|
||||
<Reference Include="System.Core" />
|
||||
@ -74,5 +94,9 @@
|
||||
<None Include="App.config" />
|
||||
<None Include="packages.config" />
|
||||
</ItemGroup>
|
||||
<ItemGroup>
|
||||
<Content Include="nfd.dll" />
|
||||
<Content Include="nfd_x86.dll" />
|
||||
</ItemGroup>
|
||||
<Import Project="$(MSBuildToolsPath)\Microsoft.CSharp.targets" />
|
||||
</Project>
|
BIN
NativeFileDialogSharpSandboxNetFramework/nfd.dll
Normal file
BIN
NativeFileDialogSharpSandboxNetFramework/nfd.dll
Normal file
Binary file not shown.
BIN
NativeFileDialogSharpSandboxNetFramework/nfd_x86.dll
Normal file
BIN
NativeFileDialogSharpSandboxNetFramework/nfd_x86.dll
Normal file
Binary file not shown.
@ -1,5 +1,4 @@
|
||||
<?xml version="1.0" encoding="utf-8"?>
|
||||
<packages>
|
||||
<package id="Microsoft.NETCore.Platforms" version="6.0.1" targetFramework="net462" />
|
||||
<package id="NativeFileDialogSharp" version="0.4.4" targetFramework="net462" />
|
||||
<package id="NativeFileDialogSharp" version="0.5.0" targetFramework="net462" />
|
||||
</packages>
|
Loading…
Reference in New Issue
Block a user