private async Task <string> DownloadDatasheet(ISearchResult item) { // Create a new 0 byte temporary file placeholder //var tempfile = System.IO.Path.GetTempFileName(); string temppath = System.IO.Path.GetTempPath(); var tempfile = System.IO.Path.Combine(temppath, item.Filename); // Sanity check - ensure file doesn't end up outside the TEMP folder ShellOperation.ValidatePathRoot(tempfile, temppath); // Remove existing items // TODO: What if we can't remove? if (System.IO.File.Exists(tempfile)) { System.IO.File.Delete(tempfile); } // Download to temporary file // TODO: Show progress await item.DownloadDatasheetAsync(tempfile); // Keep track of it so we can delete it later temporaryFiles.Add(tempfile); temporaryFileMap[item] = tempfile; return(tempfile); }