我想獲取有關用戶使用FileOpenPicker選擇的文件的某些文件信息,但所有信息(如路徑和名稱)均爲空。當我嘗試查看對象的斷點我得到了以下信息:Windows 8應用程序FileOpenPicker np文件信息
文件= 0x03489cd4 <沒有資料,沒有加載shell32.dll中的符號>
我用下面的代碼調用FileOpenPicker和HANDELING文件
#include "pch.h"
#include "LocalFilePicker.h"
using namespace concurrency;
using namespace Platform;
using namespace Windows::Storage;
using namespace Windows::Storage::Pickers;
const int LocalFilePicker::AUDIO = 0;
const int LocalFilePicker::VIDEO = 1;
const int LocalFilePicker::IMAGES = 2;
LocalFilePicker::LocalFilePicker()
{
_init();
}
void LocalFilePicker::_init()
{
_openPicker = ref new FileOpenPicker();
_openPicker->ViewMode = PickerViewMode::Thumbnail;
}
void LocalFilePicker::askFile(int categorie)
{
switch (categorie)
{
case 0:
break;
case 1:
_openPicker->SuggestedStartLocation = PickerLocationId::VideosLibrary;
_openPicker->FileTypeFilter->Append(".mp4");
break;
case 2:
break;
default:
break;
}
create_task(_openPicker->PickSingleFileAsync()).then([this](StorageFile^ file)
{
if (file)
{
int n = 0;
wchar_t buf[1024];
_snwprintf_s(buf, 1024, _TRUNCATE, L"Test: '%s'\n", file->Path);
OutputDebugString(buf);
}
else
{
OutputDebugString(L"canceled");
}
});
}
任何人都可以看到什麼是錯的代碼或一些問題,爲應用程序爲什麼不能得到預期的工作環境中。
感謝您的回答,這正是我一直在尋找的。 – furrie 2014-11-10 17:22:28