c# - Odd test method failure - Windows security -
i'm being blind, has me stumped. following unit test fails on local machine (but not on our build server) system.unauthorizedaccessexception.
[testmethod()] public void userpreferences_localapplicationdatapath_pathalwaysexists() { //setup: proposed path , delete bottom folder , existing files string logpath = environment.getfolderpath(environment.specialfolder.localapplicationdata); string actual = system.io.path.combine(logpath, @"autoscribe\matrix\gemini"); //if folder there, first delete if (directory.exists(actual)) { //log information going on console.writeline("attempting delete " + actual + " user " + environment.username); directory.delete(actual, true); // <-throws exception here console.writeline("deleted"); } //action actual = userpreferencesmanager.localapplicationdatapath; //assert getting path forces created. assert.istrue(directory.exists(actual)); }
the reported environment.username value windows user 'owns' local appdata folder. why can't folder deleted? oddly don't have problem on machines test run on (all windows 7).
you may not able delete folder locally because still have other applications running access files in it. maybe have opened notepad check logfile in folder?
the build server not have these problems, because there no users or processes "working" on machine.
Comments
Post a Comment