Windows IoT - logging activities in C# -


for schoolproject tried communicate raspberry windows iot pc on tcp- sockets. works fine want log traffic realise if goes wrong.

so programmed logfilewriter:

 public static void write(string message)     {                         using (streamwriter w = file.appendtext("\\" + "log.txt"))             {                 logging(message, w);             }      }     public static void logging(string logmessage, textwriter w)     {         w.write("\r\nlog entry : ");         w.writeline("{0} {1}", datetime.now.timeofday, datetime.now.date);         w.writeline("  :");         w.writeline("  :{0}", logmessage);         w.writeline("-------------------------------");     } 

the problem if call log.write(message) - (log class) throws following exception:

blockquote exception thrown: 'system.unauthorizedaccessexception' in system.io.filesystem.dll

has idea why exception thrown?

isn't same normal windows? cannot write same folder exe because permissions doesn't allow it. either or because app sandboxed.

i think explains it?

https://social.msdn.microsoft.com/forums/en-us/67e9d61c-ccb6-47e4-8c7a-968166701920/c-write-to-file-on-windows-10-iot?forum=windowsiot

it says this,

i think you're supposed work storagefile , storagefolder uwp applications. used them , had no issues far. when tried work file class in first release, wasn't available @ all.

maybe changed now. try saving file in file in "c:\users\username\appdata\local\packages\yourpackage". application should have access there , maybe can use file class then.

read whole thing because mentions file io sandboxed, , provides link suggest how write file,

http://grogansoft.com/blog/?p=554


Comments

Popular posts from this blog

sublimetext3 - what keyboard shortcut is to comment/uncomment for this script tag in sublime -

java - No use of nillable="0" in SOAP Webservice -

ubuntu - Laravel 5.2 quickstart guide gives Not Found Error -