Got exception in file picker c# and XAML if choose nothing? -
this question has answer here:
- what nullreferenceexception, , how fix it? 29 answers
i have problem app made choose button select file pc got exception if didn't choose files hope can
edit: code try/catch blocks
openpicker.filetypefilter.add(".wmv"); openpicker.filetypefilter.add(".mp4"); openpicker.filetypefilter.add(".wma"); openpicker.filetypefilter.add(".mp3"); storagefile file = await openpicker.picksinglefileasync(); var stream = (dynamic)null; try { stream = await file.openasync(windows.storage.fileaccessmode.read); } catch (exception ex) { frame.navigate(typeof(music)); // optional choose page }
var stream; storagefile file; try{ file = await openpicker.picksinglefileasync(); stream = await file.openasync(windows.storage.fileacessmode.read); }catch(exception ex){ //log or } //the rest of code
Comments
Post a Comment