Try to disable them or watch the file activity with ProcMon from sysinternals.com.
Up vote 4 down vote favorite 1 share g+ share fb share tw.
At work, we have migrated from Windows XP to Windows Vista. After the migration, some of my unit tests, using nUnit, started to randomly fail with the System. UnauthorizedAccessException being thrown.
The failing tests each involve writing files used for tests stored as embedded resources in the test DLL to the current directory, running the tests, then deleting them, typically in the setup/teardown or the fixture setup/teardown, in rapid succession. I do this so that my tests are agnostic to the location on each developer's drive that they are ran from and not worrying about relative file paths. While troubleshooting this, I found that it related to the creation and deletion of the files.
On deletion, each delete follows the pattern: if( File. Exists(path) ) { File. Delete(path) } When I surround this with a try-catch block and breakpoint on the catch (if the exception was thrown), the file would already be deleted from the disk.
For the failures of file creation, usually using XmlWriter or StreamWriter, each are specified to overwrite the file if it exists. Odd thing is, while investigating, I created this C# program that seems to recreate the exception: class Program { static void Main(string args) { int I = 0; try { while (true) { System.IO. TextWriter writer = new System.IO.
StreamWriter("file. Txt"); i++; System.Console.Out. WriteLine(i); writer.
Write(i); writer.Close(); System.IO.File. Delete("file. Txt"); } } catch (System.
UnauthorizedAccessException ex) { System.Console.Out. WriteLine("Boom at: " + i.ToString()); } } } On one of our machines that still has XP on it, it will keep iterating into the hundreds of thousands without excepting until I kill it. On any of our Vista machines, it will print "Boom" anywhere between 150 and 500 iterations.
Since I do not have access to a Vista machine outside of work, I can't determine whether this particular 'quirk' is because of my employer's security configuration of Vista or Vista itself. Suffice to say, I am quite stumped. EDIT: I would like to thank everyone for their responses.
I used the Process Monitor suggested by Christian and found that the Windows Vista SearchIndexer and TortoiseSVN's TSVNCache processes were trying to access the target file while my code was running, as suggested by Martin. Thanks again. C# vb.net windows-vista windows-xp unauthorized link|improve this question edited May 5 '09 at 20:17 asked May 4 '09 at 21:52Jeras10818.
In vista, go to Performace Monitor (controlpanrl->Administrative tools) and observe the virtual bytes(for memory leaks) for your application when it is running. Performance monitor gives you a lot of details about the process you want to investigate. I suspect that your application is not releasing resources since it is working heavily on file system.
Also play around with performance monitor to try and see other measures that might have caused your issue. It is difficult to blame one or the other service with out doing little investigation.
Try switching off as many of these services as you can.
I cant really gove you an answer,but what I can give you is a way to a solution, that is you have to find the anglde that you relate to or peaks your interest. A good paper is one that people get drawn into because it reaches them ln some way.As for me WW11 to me, I think of the holocaust and the effect it had on the survivors, their families and those who stood by and did nothing until it was too late.