Windows Phone 7– Duh Moment Of The Day
November 15, 2011 Leave a comment
So I wrote this code block in a Windows Phone 7 application:
1 private void CreateNewLogFile() 2 { 3 string logFileLocation = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData); 4 if (File.Exists(logFileLocation)) 5 File.Delete(logFileLocation); 6 7 } 8
And I got this exception:
And it hit me – can’t write to the local file system of the emulator using Windows Desktop/Server constructs. To write in a Windows Phone 7 application, I need to write to the local storage. However, since I can’t read from local storage easily (no WindowsExplorer access) – I would need to write a program to get the data out. This seems more trouble than it is worth. I’ll just write to the Debug window….