Win32Exception: The directory name is invalid

后端 未结 6 582
故里飘歌
故里飘歌 2020-12-15 23:03

I\'m trying to run a process as a different user that has Administrator privilege in 2 different computers running Vista and their UAC enabled but in one of them I get a Win

6条回答
  •  南方客
    南方客 (楼主)
    2020-12-15 23:18

    Try to replace

    pInfo.WorkingDirectory = New System.IO.FileInfo(myFile).DirectoryName;
    

    with

    pInfo.WorkingDirectory = Path.GetDirectoryName(myFile);
    

    The FileInfo makes an access to the filesystem, and I would assume only the admin user has access to that directory. If it doesn't solve your problem, at least it will make your code a tiny bit faster...

提交回复
热议问题