Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/atomsk-0/NativeFiledialogNET
C# Bindings for nativefiledialog-extended
https://github.com/atomsk-0/NativeFiledialogNET
csharp csharp-library filedialog nativefiledialog nativefiledialog-extended
Last synced: about 1 month ago
JSON representation
C# Bindings for nativefiledialog-extended
- Host: GitHub
- URL: https://github.com/atomsk-0/NativeFiledialogNET
- Owner: atomsk-0
- License: zlib
- Created: 2024-04-22T11:14:15.000Z (9 months ago)
- Default Branch: master
- Last Pushed: 2024-04-24T15:48:07.000Z (9 months ago)
- Last Synced: 2024-05-19T20:34:45.683Z (8 months ago)
- Topics: csharp, csharp-library, filedialog, nativefiledialog, nativefiledialog-extended
- Language: C#
- Homepage: https://www.nuget.org/packages/NativeFileDialogNET
- Size: 426 KB
- Stars: 0
- Watchers: 1
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
# NativeFileDialogNET
NativeFileDialogNET is a C# binding for the [nativefiledialog-extended](https://github.com/btzy/nativefiledialog-extended) library. This project allows you to use native file dialog functionalities in your C# applications.
## Usage
Here is a simple example of how to use the library:
```csharp
using System.Text;
using NativeFileDialogNET;using var selectFileDialog = new NativeFileDialog()
.SelectFile()
.AddFilter("Text Files", "txt") // Optionally add filters
.AllowMultiple(); // Optionally allow multiple selectionsDialogResult result = selectFileDialog.Open(out string[]? output, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
StringBuilder builder1 = new();
if (result == DialogResult.Okay && output != null)
{
foreach (string file in output)
{
builder1.Append(file).Append(", ");
}
}
Console.WriteLine(result == DialogResult.Okay ? $"Selected file(s): {builder1}" : "User canceled the dialog.");using var selectFolderDialog = new NativeFileDialog()
.SelectFolder()
.AllowMultiple(); // Optionally allow multiple selectionsresult = selectFolderDialog.Open(out string[]? output2, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments));
StringBuilder builder2 = new();
if (result == DialogResult.Okay && output2 != null)
{
foreach (string file in output2)
{
builder2.Append(file).Append(", ");
}
}
Console.WriteLine(result == DialogResult.Okay ? $"Selected folder(s): {builder2}" : "User canceled the dialog.");using var saveFileDialog = new NativeFileDialog()
.SaveFile()
.AddFilter("Text Files", "*.txt"); // Optionally add filtersresult = saveFileDialog.Open(out string? saveFile, Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments), "DefaultName.txt");
Console.WriteLine(result == DialogResult.Okay ? $"Selected file: {saveFile}" : "User canceled the dialog.");
```Contributions are welcome! Please feel free to submit a pull request.
## License
This project is licensed under the zlib License. See the LICENSE file for details.