Click here to Skip to main content
Rate this: bad
good
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
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 :
 
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 30-Jun-12 19:51pm
Edited 30-Jun-12 19:52pm
v2

1 solution

Rate this: bad
good
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: 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.
  Permalink  

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

  Print Answers RSS
0 OriginalGriff 220
1 ProgramFOX 120
2 Richard MacCutchan 100
3 kbrandwijk 90
4 ChauhanAjay 80
0 Sergey Alexandrovich Kryukov 9,050
1 OriginalGriff 8,151
2 CPallini 2,613
3 Richard MacCutchan 2,221
4 Abhinav S 1,928


Advertise | Privacy | Mobile
Web04 | 2.8.140827.1 | Last Updated 1 Jul 2012
Copyright © CodeProject, 1999-2014
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