Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. General Programming
  3. C / C++ / MFC
  4. SetCurrentDirectory

SetCurrentDirectory

Scheduled Pinned Locked Moved C / C++ / MFC
tutorial
3 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • S Offline
    S Offline
    sarfaraznawaz
    wrote on last edited by
    #1

    hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ

    T A 2 Replies Last reply
    0
    • S sarfaraznawaz

      hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ

      T Offline
      T Offline
      tolw
      wrote on last edited by
      #2

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

      1 Reply Last reply
      0
      • S sarfaraznawaz

        hi i have use the GetCurrentDirectory now i want to change the Directory with SetCurrentDirectory can any one explain with Example thanks SARFARAZ

        A Offline
        A Offline
        App_
        wrote on last edited by
        #3

        #include <windows.h>
        #include <stdio.h>
        #define BUFFER_SIZE 200

        int 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;
        }

        1 Reply Last reply
        0
        Reply
        • Reply as topic
        Log in to reply
        • Oldest to Newest
        • Newest to Oldest
        • Most Votes


        • Login

        • Don't have an account? Register

        • Login or register to search.
        • First post
          Last post
        0
        • Categories
        • Recent
        • Tags
        • Popular
        • World
        • Users
        • Groups