I developed a custom screen saver in WPF (with the extension .scr) but I got an issue : When screen saver is run by Windows, the application stop imediately. After some tests, I found that it comes from the fact that I'm creating/writing files.
I tried :
But nothing works...
Any idea ?
Note : I need to write lot of lines in my file
Ok, my bad... I found where were my problemss.
First, screen saver does not have permission to write in Windows folder.
Then, I was trying to write in a special folder using Environment.SpecialFolder.MyDocuments
but this property return the name of the folder. So I need to use Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments)
instead.
Finally, I was trying to write a file in a folder that didn't exists. I thought that the folder would be created automatically but I was wrong...
As suggested by @elgonzo, I have added exception handler and displayed the error messages in a message box using MessageBox.Show(log)
.