How to get user AppData folder in C#

2 Answers

0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData);
        }
    }
}




/*
 * run:
 *
 * "C:\\Users\\ABC\\AppData\\Roaming"
 * 
 */

 



answered Sep 2, 2023 by avibootz
0 votes
namespace WinFormsApp1
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            label1.Text = Environment.GetFolderPath(Environment.SpecialFolder.LocalApplicationData);
        }
    }
}




/*
 * run:
 *
 * "C:\\Users\\ABC\\AppData\\Local"
 * 
 */

 



answered Sep 2, 2023 by avibootz

Related questions

1 answer 131 views
1 answer 83 views
83 views asked Aug 22, 2023 by avibootz
1 answer 139 views
139 views asked Jan 14, 2017 by avibootz
...