Archived

This topic is now archived and is closed to further replies.

Default Directory

This topic is 6116 days old which is more than the 365 day threshold we allow for new replies. Please post a new topic.

If you intended to correct an error in the post then please contact us.

Recommended Posts

How to change default directory? For example, i want to open file at: "\Graphics\graph.bmp", but fopen("\\Graphics\\graph.bmp", "r") doesn''t work. Help me, pls.

Share this post


Link to post
Share on other sites
Guest Anonymous Poster
FILE *MyFile = fopen("Graphics\\graph.bmp","r");

Share this post


Link to post
Share on other sites
OK. Thanx. But what if: My program is at "C:\Prog\my.exe" and i want to run another program from it, wich is at
"C:\Prog\Prog2\my2.exe" (i use ShellExecute function). And my2.exe uses some resources from it''s own dir. But in this case, default directory is "C:\Prog", not "C:\Prog\Prog2" and my2.exe is not running without resources. So, i need to change default directory to "C:\Prog\Prog2" What should i do? Help me, pls.

Share this post


Link to post
Share on other sites

SetCurrentDirectory



The SetCurrentDirectory function changes the current directory for the current process.


BOOL SetCurrentDirectory(
LPCTSTR
lpPathName // pointer to name of new current directory
);

Parameters




lpPathName


Pointer to a null-terminated string that specifies the path to the new current directory. This parameter may be a relative path or a fully qualified path. In either case, the fully qualified path of the specified directory is calculated and stored as the current directory.


Return Values



If the function succeeds, the return value is nonzero.



If the function fails, the return value is zero. To get extended error information, call GetLastError.


Remarks



Each process has a single current directory made up of two parts:



  • A disk designator that is either a drive letter followed by a colon, or a server name and share name (\\servername\sharename)


  • A directory on the disk designator

Share this post


Link to post
Share on other sites