mirror of
https://github.com/AssetRipper/NativeFileDialogs.NET.git
synced 2026-11-13 20:05:46 -10:00
Write first example
This commit is contained in:
2 files changed
+57
No files matched your search
+15
@@ -0,0 +1,15 @@
|
||||
<Project Sdk="Microsoft.NET.Sdk">
|
||||
|
||||
<PropertyGroup>
|
||||
<OutputType>Exe</OutputType>
|
||||
<TargetFramework>net6.0</TargetFramework>
|
||||
<AllowUnsafeBlocks>true</AllowUnsafeBlocks>
|
||||
<ImplicitUsings>enable</ImplicitUsings>
|
||||
<Nullable>enable</Nullable>
|
||||
</PropertyGroup>
|
||||
|
||||
<ItemGroup>
|
||||
<ProjectReference Include="..\NativeFileDialogs.AutoGen\NativeFileDialogs.AutoGen.csproj" />
|
||||
</ItemGroup>
|
||||
|
||||
</Project>
|
||||
@@ -0,0 +1,42 @@
|
||||
// Copyright (c) Speykious
|
||||
// This file is part of NativeFileDialogs.NET.
|
||||
// NativeFileDialogs.NET is licensed under the Zlib License. See LICENSE for details.
|
||||
|
||||
using NativeFileDialogs.AutoGen;
|
||||
|
||||
unsafe
|
||||
{
|
||||
nfd.NFD_Init();
|
||||
|
||||
NfdnfilteritemT[] filterItem = new[]
|
||||
{
|
||||
new NfdnfilteritemT
|
||||
{
|
||||
Name = "Source code",
|
||||
Spec = "c,cpp,cc",
|
||||
},
|
||||
new NfdnfilteritemT
|
||||
{
|
||||
Name = "Headers",
|
||||
Spec = "h,hpp",
|
||||
},
|
||||
};
|
||||
|
||||
sbyte* outPathPtr;
|
||||
NfdresultT result = nfd.NFD_OpenDialogN(&outPathPtr, filterItem, (uint)filterItem.Length, null);
|
||||
switch (result)
|
||||
{
|
||||
case NfdresultT.NFD_OKAY:
|
||||
Console.WriteLine("Success!");
|
||||
Console.WriteLine(new string(outPathPtr));
|
||||
break;
|
||||
case NfdresultT.NFD_CANCEL:
|
||||
Console.WriteLine("User pressed Cancel.");
|
||||
break;
|
||||
default:
|
||||
Console.WriteLine($"Error: {nfd.NFD_GetError()}");
|
||||
break;
|
||||
}
|
||||
|
||||
nfd.NFD_Quit();
|
||||
}
|
||||
Reference in new issue
Block a user