none
FileSavePicker如何指定筛选器?(C++) RRS feed

答案

  • 我用的这个办法:

    	auto plainTextExtensions = ref new Platform::Collections::Vector<String^>();
    	plainTextExtensions->Append(".txt");
    	picker->FileTypeChoices->Insert("PlainText", plainTextExtensions);


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年5月16日 7:54
    版主

全部回复

  • 其中主要是如何定义筛选器,我的代码是:

    auto Picker = ref new Windows::Storage::Pickers::FileSavePicker();
    Picker->FileTypeChoices->Insert();//这句代码怎么写?
    create_task(Picker->PickSaveFileAsync()).then([this](Windows::Storage::StorageFile^ file){
    //省略
    });


    2014年5月16日 4:07
  • 首先,FileOpenPicker是用来打开文件,FileSavePicker是用来保存文件。

    那么我就当你问的是FileOpenPicker(其实FileSavePicker原理是一样的),

    	auto picker = ref new FileOpenPicker();
    	picker->ViewMode = PickerViewMode::List;
    	picker->SuggestedStartLocation = PickerLocationId::DocumentsLibrary;
    	picker->FileTypeFilter->Append(".txt");
    	picker->FileTypeFilter->Append(".jpg");
    
    	task<StorageFile^> m_pickFileTask(picker->PickSingleFileAsync());
    	m_pickFileTask.then([this](StorageFile^ file)
    	{
    		//do something here.
    		String^ fileName = file->DisplayName->ToString();
    	});

    --James


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年5月16日 7:24
    版主
  • FileSavePicker好像没有Append,这就是我需要问的关键。
    2014年5月16日 7:32
  • 我用的这个办法:

    	auto plainTextExtensions = ref new Platform::Collections::Vector<String^>();
    	plainTextExtensions->Append(".txt");
    	picker->FileTypeChoices->Insert("PlainText", plainTextExtensions);


    <THE CONTENT IS PROVIDED "AS IS" WITHOUT WARRANTY OF ANY KIND, WHETHER EXPRESS OR IMPLIED>
    Thanks
    MSDN Community Support

    Please remember to "Mark as Answer" the responses that resolved your issue. It is a common way to recognize those who have helped you, and makes it easier for other visitors to find the resolution later.

    2014年5月16日 7:54
    版主
  • 完全成功
    2014年5月16日 9:12