NET USE COMMAND FAILS WITH ACCESS DENIED AFTER UPDATE TO .NET 6.0 / 7.0

Steph (ZA-DUR) 0 Reputation points
2023-03-09T13:14:30.1866667+00:00

User's image

After upgrade to either .net 6.0 or 7.0 solution fails at the Process S0tart () method with permission on the working directory as per above screen .Please advise what is causing the net use to fail on frameworks.

Developer technologies .NET Other
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Jack J Jun 25,296 Reputation points
    2023-03-10T05:55:56.1833333+00:00

    @Steph (ZA-DUR), Welcome to Microsoft Q&A, based on my test, I reproduced the same problem. I could use the code to open a folder in .NET Framework but I meet the same error with you when used the code in .NET 6 app.

    After checking the Microsoft Learning Process.Start Method, I find that there is no related description about the difference between .net frramework app and .net app.

    However, I recommend that you could use the following method to open the folder without the exception.

    string path = "C:\\Videos";
    Process.Start(Environment.GetEnvironmentVariable("WINDIR") +
        @"\explorer.exe", path);
    
    

    Hope my solution could help you.

    Best Regards,

    Jack


    If the answer is the right solution, please click "Accept Answer" and upvote it.If you have extra questions about this answer, please click "Comment".

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.