I am trying to write an application which can download a file from a server I am using a file save picker along with the c++ BackgroundDownloader
since there may be different files from the server I want to append the file extension dynamically by splitting the specified URI .Below is the code I am using for this.
Uri^ source = ref new Uri(StringTrimmer::Trim(serverAddressField->Text));
String^ filenameExt= serverAddressField->Text;
const wchar_t* pntr=filenameExt->Data();
int l= filenameExt->Length();
auto temp =std::map<wchar_t,String^>();
auto test= temp.find(filenameExt->Data()[l-3]);
String^ destination1 = StringTrimmer::Trim(fileNameField->Text);
FileSavePicker^ savePicker = ref new FileSavePicker();
savePicker->SuggestedStartLocation = PickerLocationId::DocumentsLibrary;
auto plainTextExtensions = ref new Platform::Collections::Vector<String^>();
plainTextExtensions->Append(".pdf");
plainTextExtensions->Append(".txt");
savePicker->FileTypeChoices->Insert("Portable Document file", plainTextExtensions);
savePicker->FileTypeChoices->Insert("Plain text", plainTextExtensions);
savePicker->SuggestedFileName = "New Document";
create_task(savePicker->PickSaveFileAsync()).then([this](StorageFile^ file)
{
Uri^ source = ref new Uri("http://www.microsoft.com/about/mspreview/windows8/Windows8_RP_Product_guide.pdf");
BackgroundDownloader^ downloader = ref new BackgroundDownloader();
DownloadOperation^ download = downloader->CreateDownload(source, file);
/* BackgroundDownloader^ downloader = ref new BackgroundDownloader();
DownloadOperation^ download = downloader->CreateDownload(source, destinationFile);*/
Output->Text="Downloading " + source->AbsoluteUri + " to " + file->Name + ", " + download->Guid;
// Attach progress and completion handlers.
HandleDownloadAsync(download, true);
I tried to split the string using the following code but its not working properly.
const wchar_t* pntr=filenameExt->Data();
int l= filenameExt->Length();
auto temp =std::map<wchar_t,String^>();
auto test= temp.find(filenameExt->Data()[l-3]);
Don't mind for the silly question. As this is the first time I am working with c++ .