SetCurrentDirectory
-
hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ
-
hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ
Well, the MSDN can, as always: SetCurrentDirectory[^] If after reading the article something is still unclear, please post a detailed description (with source code showing what you have tried). It's hard to target a specific problem with a general question...
-
hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ
#include <windows.h>
#include <stdio.h>
#define BUFFER_SIZE 200int main()
{
TCHAR infoBuf[BUFFER_SIZE];// Change accordingly to other path of your machine
TCHAR lpPathName[200] = "c:\\";// get the current working directory
if(!GetCurrentDirectory(BUFFER_SIZE, infoBuf)) printf("GetCurrentDirectory() failed!\n");printf("Your current directory is: %s\n", infoBuf); printf("Changing directory...\n");
// set to current working directory
if(!SetCurrentDirectory(lpPathName)) printf("SetCurrentDirectory() failed!\n");// do some verification...
if(!GetCurrentDirectory(BUFFER_SIZE, infoBuf)) printf("GetCurrentDirectory() failed!\n");printf("Your current directory is: %s\n", infoBuf);
// get and display the Windows directory.
if(!GetWindowsDirectory(infoBuf, BUFFER_SIZE)) printf("GetWindowsDirectory() failed!\n");printf("Your Windows directory is: %s\n", infoBuf);
// get and display the system directory.
if(!GetSystemDirectory(infoBuf, BUFFER_SIZE)) printf("GetSystemDirectory() failed!\n");printf("Your system directory is: %s\n", infoBuf);
return 0;
}