Search code examples
c#.netresx

Access and read data from multiple *.resx files


I am new to C# .NET.

I need to access *.resx files from my local folder and then retrieve data from each *.resx files. I am creating a windows application for that.

So first, once I give path to that folder, it found the files there, but now, how can I read those file and get data from them to a temporary database on RAM.

private void buttonBrowseSource1_Click(object sender, EventArgs e)

{

        FolderBrowserDialog selectPathDialog = new FolderBrowserDialog();
        if (selectPathDialog.ShowDialog() == DialogResult.OK)
        {
            DirectoryInfo di = new DirectoryInfo(selectPathDialog.SelectedPath);
            FileInfo[] RESXFiles = di.GetFiles("*.resx");

            if (RESXFiles.Length == 0)
            {

                UpdateStatus("No RESX files found in this directory. Please check the folder/path again.");
            }
            else
            {

                UpdateStatus("Total " + RESXFiles.Length + " RESX files found in this directory.);
                textBoxSource1.Text = selectPathDialog.SelectedPath;

            }
        }
        else
        {
            UpdateStatus("Missing directory! Please try again.");
        }
    }

Thank you so much.


Solution

  • Use the ResXResourceReader Class for this.