1、C++:

  GetCurrentDirectory()             // 获取当前进程的工作目录  

  SetCurrentDirectory()             // 设置当前进程的工作目录  

  VS 当前路径指定为 exe 所在的路径:
   char sBuf[1024];
      char *ptr;
      if (GetModuleFileNameA(NULL, sBuf, sizeof(sBuf)))
      {
          ptr = strrchr(sBuf, '\\');
          if (ptr)
              *ptr = '\0';
          SetCurrentDirectoryA(sBuf);
      }
  

2、C#:  

  System.IO.Directory.GetCurrentDirectory()              // 获取当前进程的工作目录

  System.IO.Directory.SetCurrentDirectory()              // 设置当前进程的工作目录

  Application.StartupPath                           // 应用程序启动目录

  AppDomain.CurrentDomain.SetupInformation.ApplicationBase     // 应用程序启动目录  

  // 当前路径指定为 exe 所在的路径
       Directory.SetCurrentDirectory(AppDomain.CurrentDomain.SetupInformation.ApplicationBase);

 

  

 

posted on 2018-05-24 18:04  青叶煮酒  阅读(704)  评论(0编辑  收藏  举报