VS2008设置有关问题

VS2008设置问题
我在VS2008下编写程序
现在出现问题如下:
1.在exe程序所在目录下,双进exe程序,配置文件加载成功
2.在VS中,编译后直接按F5进行运行,配置文件加载失败

因为我的配置文件加载方式是  .\\bin\\Debug\\xxx.xml 这种形式,设置的是相对路径
也就是说,在VS中启动程序,和直接双击运行程序,默认的当前路径是不一致的,怎么修改?

求大神指点,改为绝对路径就算了,要是放在SVN上,每个人都要重新设置一遍
------解决思路----------------------
可以使用绝对路径
------解决思路----------------------
_chdir, _wchdir
Change the current working directory.

int _chdir( const char *dirname );

int _wchdir( const wchar_t *dirname );

Routine Required Header Optional Headers Compatibility 
_chdir <direct.h> <errno.h> Win 95, Win NT 
_wchdir <direct.h> or <wchar.h> <errno.h> Win NT 


For additional compatibility information, see Compatibility in the Introduction.

Libraries

LIBC.LIB Single thread static library, retail version 
LIBCMT.LIB Multithread static library, retail version 
MSVCRT.LIB Import library for MSVCRT.DLL, retail version 


Return Value

Each of these functions returns a value of 0 if successful. A return value of –1 indicates that the specified path could not be found, in which case errno is set to ENOENT.

Parameter

dirname

Path of new working directory

Remarks

The _chdir function changes the current working directory to the directory specified by dirname. The dirname parameter must refer to an existing directory. This function can change the current working directory on any drive and if a new drive letter is specified in dirname, the default drive letter will be changed as well. For example, if A is the default drive letter and \BIN is the current working directory, the following call changes the current working directory for drive C and establishes C as the new default drive:

_chdir("c:\\temp");

When you use the optional backslash character (\) in paths, you must place two backslashes (\\) in a C string literal to represent a single backslash (\).

_wchdir is a wide-character version of _chdir; the dirname argument to _wchdir is a wide-character string. _wchdir and _chdir behave identically otherwise.

Generic-Text Routine Mapping:

TCHAR.H Routine  _UNICODE & _MBCS Not Defined _MBCS Defined _UNICODE Defined 
_tchdir _chdir _chdir _wchdir 


Example

/* CHGDIR.C: This program uses the _chdir function to verify
 * that a given directory exists.
 */

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

void main( int argc, char *argv[] )
{
   if( _chdir( argv[1] )   )
      printf( "Unable to locate the directory: %s\n", argv[1] );
   else
      system( "dir *.wri");
}


Output

 Volume in drive C is CDRIVE
 Volume Serial Number is 0E17-1702

 Directory of C:\write

04/21/95  01:06p                 3,200 ERRATA.WRI
04/21/95  01:06p                 2,816 README.WRI
               2 File(s)          6,016 bytes
                             71,432,116 bytes free


Directory Control Routines

See Also   _mkdir, _rmdir, system

------解决思路----------------------
“.\\”所代表的路径即“当前路径”,可以用GetCurrentDirectory()获取,用SetCurrentDirectory()设置。而默认的"当前路径"在你直接双击运行和调试运行时是不一样的,不过这个"当前路径"可以在程序运行起来以后,加载配置文件以前通过上述API修改,这样可保证无论怎么运行都能正确加载配置文件。当然更好的办法是用GetModuleFileName(第一个参数用NULL)来获取程序exe所在的路径,然后根据该路径得到配置文件路径,再加载配置文件,这样就不会受"当前路径"的影响了。
------解决思路----------------------
一般情况下,配置文件要跟exe文件在同一个大的目录下,或者说exe文件与配置文件所在目录的所属关系是兄弟关系,可以通过./../相对路径查找

另外一种办法是通过“生成后事件”把存在的配置文件拷贝到当前VS执行目录下,这样exe文件就可以找得到了(当然也是要通过写代码找的)
------解决思路----------------------
写代码获取你exe所在的路径,然后在找配置文件路径,写在代码里
GetModuleFileName再截取出路径,搜索一下例程多的是