Vista remembers? - Access to System32 somehow special?
Hi everybody.Just spent some very frustrating houres fighting with Vista.Wanted to know, what exception I get, when I write to a folder where I hav no rights. OK - just some lines and I'll see:StreamWriter sw = null;try{sw = new StreamWriter( @"C:\Windows\System32\MyService\test.txt", true, Encoding.GetEncoding( "windows-1252" ) );sw.WriteLine("sometext" );}catch (Exception e){MessageBox.Show( e, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning );}finally{if (sw != null) sw.Close();}I tookC:\Windows\System32\MyService\test.txt because I was to lazy to change the rights of some testpath and I know (knew?) I could not write there as 'normal user'. The result: no exception and no file???what the? check the path - OKtry to write fromcmd (copy con:C:\Windows\System32\MyService\test.txt)-Access is denied.0 file(s) copied.So I change the rights for Users on C:\Windows\System32\MyService to Full Access.Rerun of prog gives the same results??? copy con: now worksAfter some headscratching and wondering I changed the filename in the program to test2.txt. Now it writes the file. Back to test.txt - noexception and no writing???Took away Full Access (and write and modify and write) and tried test3.txt. As expected no and no. Back to Full Access - test3.txt no and no, test4.txt no problem.I created a new folder under System32. Same results as before.If I do the same with a path like C:\testpath, everything works as expected. Normaly I can write, if I take away some rights (deny write or something) I get my exception (UnauthorizedAccessException by the way)So how does .NET or something first supress an exception and then somehow remember it later?Please helpNorbertPS. please forgive anyerrors in my english
March 7th, 2009 8:33pm

Hi,I think you have a better shot at a reply on the MSDN Forums (Developer):http://forums.microsoft.com/msdn/default.aspx?siteid=1 Victor Constantinescu - MVP Security, MCTS
Free Windows Admin Tool Kit Click here and download it now
March 8th, 2009 4:09pm

This topic is archived. No further replies will be accepted.

Other recent topics Other recent topics