调用GetOpenFileName(); UWP中不支持函数
我测试那段代码。 (已核对的答案中的代码)
Using GetOpenFileName instead of OpenFileDialog
我改变的东西只是'CharSet.Auto'到'CharSet.Unicode' ('CharSet.Auto'未在UWP环境中编译)
但它不起作用。
OpenFileName ofn = new OpenFileName();
ofn.structSize = Marshal.SizeOf(ofn);
ofn.filter = "Log files\0*.log\0Batch files\0*.bat\0";
ofn.file = new String(new char[256]);
ofn.maxFile = ofn.file.Length;
ofn.fileTitle = new String(new char[64]);
ofn.maxFileTitle = ofn.fileTitle.Length;
ofn.initialDir = "C:\\";
ofn.title = "Open file called using platform invoke...";
ofn.defExt = "txt";
bool bResult = false;
if (bResult = LibWrap.GetOpenFileName(ofn))
{
}
GetOpenFileName()result(bResult)只是'false'。
由于限制自定义文件夹路径,我无法使用FilePicker。