Temp directory using virtualized path on some computers
Asked Answered
B

1

10

In my Silverlight application I'm using regular SaveFileDialog for prompt user to save some file.

The problem is that on some Windows 7 computers, if user use IE in protected mode, and try to save to for example on desktop, path for saving ends up like this:

C:\Users\<user>\Appdata\Local\Microsoft\Windows\Temporary Internet Files\Virtualized\C\Users\<user>\Desktop

Does anybody know where I can find flag or value indicating that this path will be used instead of regular one on windows?

Thank you

Bostwick answered 28/2, 2013 at 17:1 Comment(6)
Have you tried using Path.GetTempPath Method?Zig
Do you run your application in "Out of Browser"-Mode?Fauman
assuming that the Path will always look like this when IE is in Protection-Mode you could try detecing if IE is in ProtectionMode via Interop and this Method [IEIsProtectedModeProcess] for more Info check out this link codeproject.com/Articles/18866/… (unfortunately this is all C++)Hollister
@Kokulan that is method that I'm usingBostwick
@Fauman yes, I have elevated privileges, it is configured properlyBostwick
@sine I can try but not sure it will solve my problem because it doesn't happen on my machine with similar conditions, so I guess something else is involved in this 'virtualized' pathsBostwick
H
6

So after a bit of research I´m afraid there is no Flag or Value which Indicates a Virtualized Path...

I know it´s a little bit russian but assuming that this is static

\Microsoft\Windows\Temporary Internet Files\Virtualized\

You could do something like this to check if the Path points to the Virtualized Folder

public static bool IsPathVirtualized(string path)
{
        bool isVirtualized = false;
        string pathToVirtualizedUserFolder = Path.Combine
        (
            Environment.SpecialFolder.LocalApplicationData + 
            @"Microsoft\Windows\Temporary Internet Files\Virtualized\"
        );

        if(path.StartsWith(pathToVirtualizedUserFolder))
        {
            isVirtualized = true;
        }
        return isVirtualized;
}
Hollister answered 6/3, 2013 at 10:32 Comment(1)
thanks, similar thing I do and it works but I was looking for better solution, don't feel comfortable with string compare...Bostwick

© 2022 - 2024 — McMap. All rights reserved.