0

I have a pc with 2 users : administrator one and a standard one. My C# program is running in the standard user but with admin right (using the other account credentials).

When I try to open an image with Process.Start(@"C:\Users\AdminUser\Documents\Image.png"); The windows photos app is coming up, with a message that the file was moved or renamed. I checked the file properties inside the photos app and it turns out that the path it's looking for is "C:\Users\StandardUser\Documents\Image.png" and thus can't find the image.

Does someone know why it's looking for different path?

Lior v
  • 464
  • 3
  • 12
  • Have you tried passing the user credentials to [`Start()`](https://learn.microsoft.com/en-us/dotnet/api/system.diagnostics.process.start?view=net-7.0#system-diagnostics-process-start(system-string-system-string-system-security-securestring-system-string)) explicitly? – Mushroomator Apr 11 '23 at 18:43
  • The problem with passing credentials is that my program is installed on other computers as well, so I have no way to get the admin credentials. – Lior v Apr 11 '23 at 18:50
  • Let me get this straight, the computer has two users and the program installed for both users? Then check which user is logged in and then use the right path in your code – Son of Man Apr 11 '23 at 19:01
  • The program is installed only for the standard user, but is running as admin (I need admin rights for other part of the program). The problem when I try to open file located in the admin user directory as described in the question. – Lior v Apr 11 '23 at 19:04

0 Answers0