Should I use AppDomain.CurrentDomain.BaseDirectory or System.Environment.CurrentDirectory?

前端 未结 7 1564
被撕碎了的回忆
被撕碎了的回忆 2020-11-28 04:28

I have two exe files in the same folder, I can run exe2 from a button in exe1. Today I was observing a customer over a remote (terminal services) session and exe2 failed to

7条回答
  •  心在旅途
    2020-11-28 05:00

    I have also been through this few days back, as I was using

    Environment.CurrentDirectory
    

    as it was giving me issue on the production server but was working fine with my local server,

    So, I tried with

    System.AppDomain.CurrentDomain.BaseDirectory;
    

    And it worked for me in both the Environment.

    So, As all of them has said We should always go with

    System.AppDomain.CurrentDomain.BaseDirectory;
    

    as it checks the Current Domain directory for the path.

    have a look for more information

    Could not find a part of path error on server

提交回复
热议问题