C ++ Visual Studio当前工作目录 [英] C++ Visual Studio Current Working Directory

查看:190
本文介绍了C ++ Visual Studio当前工作目录的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我对此有类似的问题:
当前工作目录是Visual Studio目录

I have a similar problem to this: Current working directory is visual studio directory

除了我在Visual Studio中使用C ++项目外。有任何建议吗?

Except that I am working with a C++ project in Visual Studio. Any suggestions?

例如,如果我尝试以下帖子中的解决方案:
用于启动应用程序的GetCurrentDirectory。 c ++

For example if I try the solution in the following post: GetCurrentDirectory for startup App. c++

我明白了:

"C:\PROGRAM FILES (X86)\MICROSOFT VISUAL STUDIO 11.0\COMMON7\IDE"

但是我希望它成为项目/解决方案文件夹下的Debug文件夹。

But I want it to be the Debug folder under my project/solution folders.

推荐答案

使用 _ fullpath命令允许我提取当前目录。例如,您可以在链接的页面上修改示例代码:

Using the _fullpath command allowed me to extract the current directory. For example you can modify the example code on the linked page :

#include <stdio.h>
#include <conio.h>
#include <stdlib.h>
#include <direct.h>

void PrintFullPath( char * partialPath )
{
   char full[_MAX_PATH];
   if( _fullpath( full, partialPath, _MAX_PATH ) != NULL )
      printf( "Full path is: %s\n", full );
   else
      printf( "Invalid path\n" );
}

int main( void )
{
   // Get current directory
   PrintFullPath( ".\\" );
}

这篇关于C ++ Visual Studio当前工作目录的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆