Openfiledialog and savefiledialog crashes on cancel

Hmm, I can’t see anything wrong with the code. Perhaps someone who have done this before can help out.