Click here to Skip to main content
15,887,676 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more: , +
Opening an excel sheet using StartInfo is not working.

What I have tried:

I tried impersonating using the impersonation class, it is not working. Then I passed my user credential using Process.StartInfo.UserName and Process.StartInfo.Password, it is not working. I am opening a CMD prompt with a different user credential, then I am using the command "/C start excel '\\mynetwork\filename.xls'"
Posted
Updated 17-Jun-16 4:19am
v2

The user you impersonate has to have permissions to the network share you're trying to open the file from.

Also, a UNC path is \\servername\sharename\folderpath\filename
 
Share this answer
 
Comments
Strikerzz Arut 17-Jun-16 10:18am    
The user has the full control over the network path which I am trying to access.

The UNC path is similar to the one you have given.
Dave Kreskowiak 17-Jun-16 10:19am    
OK, without seeing the code you wrote to do this, it's pretty much impossible to tell you what you're doing wrong.
Strikerzz Arut 17-Jun-16 10:20am    
Sorry about that and I have posted my answer below. Using impersonation class won't work. We should use Process to open the Excel in different user credentials.
Process.StartInfo.LoadUserProfile is set to true and it does the trick.
 
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