C++ Code Sample: Get AppData Path

C++ Code Sample: Get AppData Path

Appdata thường được sử dụng làm thư mục để lưu trữ các file config, file cấu hình của một phần mềm.

Mẫu code dưới đây sẽ giúp bạn lấy được đường dẫn của thư mục appdata trong windows.

std::string GetPathAppdata() 
{ 
    char* Path; size_t length;
    _dupenv_s(&Path, &length, "appdata");
    std::string pathStr(Path);
    int idx = pathStr.find("Roaming");
    pathStr = pathStr.substr(0, idx);
    return pathStr; 
}

END

Leave a Reply

Your email address will not be published. Required fields are marked *

This site uses Akismet to reduce spam. Learn how your comment data is processed.