Click here to Skip to main content
15,891,184 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
C#
Process.Start()
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 :

C#
Using(WindowsImpersonationContext impersonateUser = LogonMethod())
{
    ProcessStartInfo pInfo = new ProcessStartInfo(filePathWithExtension);
    pInfo.Domain = MyDomainName;
    pInfo.UseShellExecute = false;
    Process.Start(pInfo);
}


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

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: http://www.daniweb.com/software-development/csharp/threads/225868/how-to-programmatically-create-user-profile-c[^]. 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.
 
Share this answer
 

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