views:

148

answers:

5

I have some code that is reading a config file, but when I open the file in TextPad, I see different values than my application does. I checked it with Notepad. Notepad agrees with my application, TextPad shows something else.

This is on Vista x64 Business.

Any idea what could be causing this? I've looked in the Context Menu->Properties->Previous Versions details, but it says "There are no previous versions available".

Here's the steps to replicate (I can't make it happen reliably):

  1. Installed .NET app in Program files.
  2. That app reads the config file, but is falling over.
  3. I manually edit that config file in Textpad.
  4. The change doesn't take effect.
  5. I open the config file in Notepad, and see something different.
  6. Try making the change in Notepad and saving, and get this error message:

Notepad

Cannot create the C:\Program Files (x86)\Daniel Schaffer\WorkingOn for FogBugz\FogBugz > WorkingOn.exe.config file.

Make sure that the path and file name are correct.

I can't put the content here as it's XML and is being encoded by Superuser.com, but here's a link to a screencast: http://screencast.com/t/zhERl7mocp4.

+2  A: 

Hi,

Sounds like a case of you don't have administrator privs, when you installed your app. Sometimes when you install an app with no admin privs, it behave really strangely because of vista security model. I had a similar problem to this last year. It wasn't the exactly, but it was strange behaviour, until I figured out it was vista's security model. It elevates it into application/user security context, from what I know, as my brain froze when I was reading about it, as it was pure muck and virtually useless from what I can see.

Try opening Textpad (excellent app) with Run as Administrator, and then edit the config. See what happens. If it stays then same then its a prives problem. If that doesn't work, deinstall you app, and then install it as an administrator. That will give the app the write admin privs to work. Then when you edit the config. See if that works.

Take a look at this. You can elevate an app to run as administrator, Using the techniques found here. How to elevate an application.. Try all these before you do a reinstall.

If that doesn't work, post your question to server fault. Also post it to a suitable MSDN forum.

Hope that help. Bob.

scope_creep
+1  A: 

This is interesting. My guess is that a Vista Feature called UAC Virtualization (aka Data Redirection) is at work here. It basically redirects legacy applications to %USERPROFILE%\AppData\VirtualStore\Program Files\... so they can write files in the program's directory.

Maybe Textpad tries to open the file in read-write mode while both your application and Notepad use it read-only? You can fire up Process Monitor to see the exact magic, and please let me know ;-)

Josef
+1  A: 

Try just to strip that whitespace character from application name; my guess is something related to canonical path building

Rubens Farias
A: 

try to copy file to another path and reopen it. see if it changes the result.

Mehran
A: 

One thing you can do is observe what exact file each of those methods ends up opening. To do this,

  • launch Process Monitor from the sysinternal suite.
  • look only for file operations (deselect registry operations on the right of the toolbar)
  • select only your own process (filter out all the processes that you don't care about, or just include your own process name in the filter list)

You can also simply use the search function for your file name, this might be the faster route.

Process monitor has helped me find so many issues it's amazing.

Bahbar