|
fileprompt
Note: DFL has its own file dialog classes named
OpenFileDialog
and SaveFileDialog.
This module contains a class named FilePrompt that wraps two of the possibly ugliest Windows API functions: GetOpenFileName and GetSaveFileName. Download here. Here is an example showing just how easy this class makes it:
private import std.stdio;
private import fileprompt;
int main()
{
FilePrompt fprompt = new FilePrompt;
if(fprompt.open(null, "Text Files (*.txt)\0*.txt\0All Files\0*.*", "test.txt"))
{
writefln("The file you selected was: %s.", fprompt.file());
}
else
{
writefln("You did not select a file.");
}
return 0;
}
This module also contains a useful function named splitFiles,
for splitting a list of files into an array.
Useful when a user is able to select multiple files in the FilePrompt, and even the command line string passed to a windows program (through WinMain or GetCommandLine):
char[][] files = splitFiles("fileprompt.d \"long filename in quotes.txt\" foo.txt");
|