December 07, 2020

C# get windows user app data folder path

 Hi folks,

Today I will explain to get the folder path of the windows user specific app data for storing any program (app) based information in C# (.NET Framework, .NET CORE, .NET 5)


Source

using System;

using System.IO;

namespace NETFrameworkConsoleApp1

{

    class Program

    {

        static void Main(string[] args)

        {

            string dir = Path.Combine(

                Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData),

                "FolderName"

            );

            Console.WriteLine("User Appdata Path: \n " + dir);

            Console.ReadLine();

        }

    }

}


Hope this helps you to customize your requirement.

References

https://docs.microsoft.com/en-us/dotnet/api/system.environment?view=net-5.0

Please share your comments and feedback to psrdotcom@gmail.com


C++ get windows user app data folder path

 Hi folks,

Today we will see how we can get the folder path of the windows user specific app data for storing any program (app) based information.


Source

#include <iostream>

#include <tchar.h>

#include <shlwapi.h>

#pragma comment(lib,"shlwapi.lib")

#include "shlobj.h"

using namespace std;

int main()

{  

    TCHAR szPath[MAX_PATH];

    // Get path for each computer, non-user specific and non-roaming data.

    if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_APPDATA, NULL, 0, szPath)))

    {

        // Append product-specific path

        PathAppend(szPath, _T("\\App Folder Path\\"));

        wcout << "User AppData Roaming Folder Path: \n" << szPath << endl << endl;

    }

    

    // Get path for each computer, non-user specific and non-roaming data.

    if (SUCCEEDED(SHGetFolderPath(NULL, CSIDL_PROGRAM_FILES, NULL, 0, szPath)))

    {

        wcout << "System Program Files Folder Path: \n" << szPath << endl << endl;

    }

    cout << "==end==";

}


Hope this helps you to customize your requirement.

References

https://docs.microsoft.com/en-us/windows/win32/shell/csidl

Please share your comments and feedback to psrdotcom@gmail.com


Featured Post

Java Introdcution

Please send your review and feedback to psrdotcom@gmail.com