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?
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,
Comments
Post a Comment