#### Archived

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

# Default Directory

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

## 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 on other sites
fopen("graphics/graph.bmp", "r");

That works on windows systems... not sure about Unix or what-have-you.

##### Share on other sites
FILE *MyFile = fopen("Graphics\\graph.bmp","r");

##### 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.

# 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

1. 1
2. 2
3. 3
Rutin
15
4. 4
khawk
14
5. 5
frob
12

• 9
• 11
• 11
• 23
• 12
• ### Forum Statistics

• Total Topics
633660
• Total Posts
3013221
×