8
votes

I've written a screen saver in C# and Windows Forms. For testing I've been lazy and just used the config file for all my settings (no settings dialog yet), but the program seems to be unable to find or read the config file when windows runs the screensaver.

It works when I use the preview button or run it manually in any way, its only when it hits the screensaver timeout that it is unable to find the config file.

Having it log AppDomain.CurrentDomain.SetupInformation.ConfigurationFile It returns the short name: C:\Windows\System32\MYSCRE~1.config Where it should be C:\Windows\System32\MyScreenSaverName.scr.Config

So I'm guessing the problem is that it can't find the config file with the short name path.

Not sure if its due to the system account which Windows 7 runs screen savers under, or something else about how it gets run. Any information would be helpful, thanks.

Edit: Trying to find any differences:

  1. Only difference I can find is that Environment.CommandLine returns C:\Windows\system32\MYSCRE~1.SCR /s when Windows runs the screen saver, but has the normal path when I run it
  2. Everything under Process.GetCurrentProcess().StartInfo is the same
  3. WindowsIdentity.GetCurrent().Name is my account name

Looking at other questions, it seems that User32 is what starts the screensavers, so I'm figuring it has to be something about how that starts up the scr process.

Work Around: Renaming my .scr file to have 8 characters or less allows it to work correctly. So that works for now, would still love to know why this problem exists.

1
I'm experiencing the same problem. But the workaround works for me too...Jan
Because the code that runs the screensavers still has the limitation of 8 characters DOS / old Windows had? Like C:\Progra~\ So if you call the AppDomain and change the config file to "a.config" maybe it will work without renaming the file to be less than 8 symbols. Like: AppDomain.CurrentDomain.SetData("APP_CONFIG_FILE","c:\\this_is_a_long_config_file.config");NOTE: This is a wild guess which is why I added it as a comment and not an answer.Pavel Donchev

1 Answers

1
votes

edit: ouch... I noticed too late that it's a 1 year old question.... well maybe someone can find this usefull anyway.


Are you sure the filesystem isn't fat/fat32 instead of ntfs?

Maybe it's a Win7 upgraded from an old fat/fat32 formatted system? (and so fs were not upgraded)?

Maybe I'm wrong, it's just my guess to see short names in place. I recently worked on a screensaver project in c# and I encountered no problems at all... I don't see short names since ages to be honest...

You should see the fs type from Disk management. Doing some research i also got this, check if FUTIL.EXE can help, there is a curious "disable8dot3" option right there:

http://commandwindows.com/fsutil.htm