Click here to Skip to main content
12,956,197 members (92,902 online)
Rate this:
Please Sign up or sign in to 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.
Posted 30-Jun-12 19:51pm
Updated 30-Jun-12 19:52pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

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)

    Print Answers RSS
Top Experts
Last 24hrsThis month
OriginalGriff 6,869
CHill60 3,550
Maciej Los 3,243
ppolymorphe 2,070
Jochen Arndt 1,973

Advertise | Privacy | Mobile
Web02 | 2.8.170525.1 | Last Updated 1 Jul 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100