locked
File.DeleteAsync alwas silently fails RRS feed

  • Question

  • I have an app that creates videos in the Videos folder. For some reason though, DeleteAysnc just silently fails. (Oddly enough, it sometimes succeeds in debug mode - admin?)

    Any help is appreciated!


    Dexter

    Friday, November 22, 2013 6:11 PM

Answers

  • Thanks for everyone's response.  There was no exception thrown, but I realized the MediaElement was still holding on to the file.  Should have thrown an exception though.  I added the lines with <<<

                     me.Stop();  // <<
                     me.Source = null; // <<
                    if (deletefile)
                    {
                        this.IsBad = true;
                        await md.File.DeleteAsync();
                
                        this.DeleteFile = true;
                    }


    Dexter

    • Marked as answer by Dexter Dengler Sunday, November 24, 2013 2:39 PM
    Sunday, November 24, 2013 2:39 PM

All replies

  • What exception are you shown? Can you show us?
    Saturday, November 23, 2013 4:29 AM
  • You have to be very careful with the Windows 8 app filing system.

    One problem that can occur is just as you try to open a file is the anti virus software tries to open it too and stops your request to open it.

    You have to be exact in catching every possible error in your code.


    n.Wright

    Sunday, November 24, 2013 1:48 AM
  • Please provide sample code to see how you use DeleteAsync. Are you awaiting it?

    Blog: http://lunarfrog.com/blog

    Sunday, November 24, 2013 2:51 AM
  • Thanks for everyone's response.  There was no exception thrown, but I realized the MediaElement was still holding on to the file.  Should have thrown an exception though.  I added the lines with <<<

                     me.Stop();  // <<
                     me.Source = null; // <<
                    if (deletefile)
                    {
                        this.IsBad = true;
                        await md.File.DeleteAsync();
                
                        this.DeleteFile = true;
                    }


    Dexter

    • Marked as answer by Dexter Dengler Sunday, November 24, 2013 2:39 PM
    Sunday, November 24, 2013 2:39 PM