locked
DownloadOperation.StartAsync() Throws System.IO.FileNotFoundException

    Question

  • I'm tearing my hair out with this one... this was all working great until today and now I can't figure out what's changed.

    Here's my block of code:

    Uri uri = new Uri("http://www.darthwhoever.com/clients/br/folder1/folder2/picture.jpg");
    
    StorageFile file = await ApplicationData.Current.LocalFolder.CreateFileAsync("picture.jpg",CreationCollisionOption.ReplaceExisting);
    
    BackgroundDownloader downloader = new BackgroundDownloader();
    
    DownloadOperation download = downloader.CreateDownload(uri,file);
    
    await download.StartAsync();

    I put breakpoints on every line and everything seems to work swimmingly (local file created and everything) until the last line, where, without fail, I now get this:

    "An exception of type 'System.IO.FileNotFoundException' occurred in mscorlib.dll but was not handled in user code

    Additional information: The system cannot find the file specified. (Exception from HRESULT: 0x80070002)"

    I can't find documentation anywhere of this HResult or a FileNotFoundException being thrown by DownloadManager.StartAsync().

    Has anyone out there ever dealt with this??

    Thanks in advance!

    Tuesday, February 25, 2014 6:43 AM

Answers

  • Finally figured it out. Apparently it has nothing to do with the code - something in the filesystem just got corrupted somehow.

    The fix for me was to uninstall the app and then launch it again out of VisualStudio.

    • Marked as answer by Andrew Ewert Tuesday, February 25, 2014 7:52 AM
    Tuesday, February 25, 2014 7:52 AM