none
[UWP][C#]Trouble downloading video file from a Web url in Win10 RRS feed

  • Question

  • Dear all,

    I am building a xaml c# UWP which is connecting to web services to download files.
    Actually file type are either image file ( .png,jpeg,tiff,...) or document like pdf and video ( .mp4, mov,..)

    To download picture file or PDF file I am using the following code :

    var s = await _environementStorageService.GetProductPhotoPath();
    					await SaveFileAsync(new Uri(p.RemoteUrl, UriKind.Absolute), s, p.FileName + "." + p.FileExtension);

    The SaveFileAsync method works correctly with picture and document file but while usinf the same with video file fails.

    Files download with 0kb, so seems SaveFileAsync is not performing correctly.

    What is the way to process video file then in UWP ?

    regards


    • Edited by Barry Wang Wednesday, April 27, 2016 7:27 AM title tag
    Tuesday, April 26, 2016 11:00 AM

Answers

All replies

  • What is your implementation of SaveFile?

    http://pauliom.wordpress.com

    Tuesday, April 26, 2016 11:15 AM
  • Here is the implementation of the SaveFileAsync Method :

    private async Task<StorageFile> SaveFileAsync(Uri fileUri, StorageFolder folder, string fileName)
    		{
    			try
    			{
    
    
    				// create the blank file in specified folder
    				var file = await folder.CreateFileAsync(fileName, CreationCollisionOption.FailIfExists);
    
    				// create the downloader instance and prepare for downloading the file
    				var backgroundDownloader = new BackgroundDownloader();
    				var downloadOperation = backgroundDownloader.CreateDownload(fileUri, file);
    
    				// start the download operation asynchronously
    				var result = await downloadOperation.StartAsync();
    				return file;
    			}
    			catch (Exception exc)
    			{
    				string s = exc.Message;
    
    			}
    			return null;
    		}
    Do you see something wierd in this ?

    Tuesday, April 26, 2016 11:28 AM
  • solve it. That was a url mistake pointing to bad location

    thks

    • Marked as answer by wakefun Tuesday, April 26, 2016 1:20 PM
    Tuesday, April 26, 2016 1:20 PM