I'm brand new to programming for Metro with Visual Studio 2012, and so far the process has been incredibly frustrating. I'm trying to write a simple app that opens a text file, changes it, and saves it. Easy, I'd expect, but apparently that's not the case! That, or I'm missing something. :)
1. My error handling sucks. I was trying to pop up a MessageDialog to notify the user of any exceptions that occur, but I learned that you can't have await (which means that you can't properly display the MessageDialog) within a catch block. I put together the solution shown below, but it's bulky and ugly. Surely there's a better way?
string ErrorMessage = "";
// do stuff here
catch (Exception ex)
ErrorMessage = ex.Message;
if (ErrorMessage != "")
MessageDialog mError = new MessageDialog(ErrorMessage, "Error");
ErrorMessage = "";
2. I can't seem to open files. At all. When I try something like this:
StorageFile file = await StorageFile.GetFileFromPathAsync(filePath);
It doesn't matter where the file is located -- c:\temp, My Documents, etc. -- the app throws an "access denied" exception. What am I missing?