Click here to Skip to main content
15,066,651 members
Please Sign up or sign in to vote.
4.00/5 (1 vote)
Hi all,
I have written a win application that works on a network.
In one of its forms user can browse and select file from local computer and add it to a list, so the application copies these files to a folder in My Network Places that no users can access to it but one that i have created already for my application so i have his username and password.Every things works fine up to here.

In this form user can also open a file by select it and press open button, so the file should open in an application that relates to its extension(for example test.xlsx should open in Excel.exe).I have used
to do this but for each extension i receive an individual error(for example "Access is denied" for NotePad and "RunTime error" for AdobeReader and "Not enough memory" for Excel).

What is my mistake?

Note : I have used ImpersonatUser to logon that user in my application.

I have used following code to open the file :

Using(WindowsImpersonationContext impersonateUser = LogonMethod())
    ProcessStartInfo pInfo = new ProcessStartInfo(filePathWithExtension);
    pInfo.Domain = MyDomainName;
    pInfo.UseShellExecute = false;

Note : My LogonMethod uses LogonUser method of advapi32.dll.
Updated 30-Jun-12 19:52pm

1 solution

To have all extension associations, your user needs a full profile. As I know, no logonType is creating or loading the profile for you. Here I found something you might find of use:[^]. Read all post carefully to copy the most complete code.
But I would not relay on associations. I would specify in a configuration file the CLSID needed for a specific extension, and look in the client registry for the application location, and start it passing the document as parameter. This way you don't need the complete profile, tehe interactive logon is enough.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900