Question

I writing an interface for legacy application which reads data from windows directory.

So i need to write data into windows directory. (Windows 8 operating system)

I am using below code to get the windows folder path to write the file.

Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.Windows), "test.txt");

As i read on MSDN, if we run application, as normal user it writes data into virtual store windows folder, but it seems it not working. I am getting access denied error.

My application build with x86 platform.

Something I am missing or any constraints for window 8 OS.

Please assist, many thanks in advance.

Was it helpful?

Solution

I found the answer to my question in manifest file default comments provided. it says,

<!-- UAC Manifest Options
            If you want to change the Windows User Account Control level replace the 
            requestedExecutionLevel node with one of the following.

        <requestedExecutionLevel  level="asInvoker" uiAccess="false" />
        <requestedExecutionLevel  level="requireAdministrator" uiAccess="false" />
        <requestedExecutionLevel  level="highestAvailable" uiAccess="false" />

            Specifying requestedExecutionLevel node will disable file and registry virtualization.
            If you want to utilize File and Registry Virtualization for backward 
            compatibility then delete the requestedExecutionLevel node.
        -->

So you need to add the manifest file and remove requestedExecutionLevel node from xml or from project properties -> Application -> Icon and manifest -> under Manifest set

Create application without a manifest

It has solved my problem.

Thanks,

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top