C# WinForm gets the storage path of the selected file

Select the file and click OK to display the absolute path of the file in the text box.

    public void getfilepath()
    {
        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Filter = "Arbitrary files (*. *)|*. *";  //type and description of the file
        if (dlg.ShowDialog() == DialogResult.OK)  //After the selection is made
        {
            string filePath = dlg.FileName;
            textBox1.Text = filePath;

        }
    }


Read More: