0

我是 C# .NET 的新手。

我需要从本地文件夹访问 *.resx 文件,然后从每个 *.resx 文件中检索数据。我正在为此创建一个 Windows 应用程序。

因此,首先,一旦我给出了该文件夹的路径,它就会在那里找到文件,但是现在,我如何读取这些文件并将数据从它们获取到 RAM 上的临时数据库中。

私人无效按钮BrowseSource1_Click(对象发送者,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.");
        }
    }

非常感谢。

4

2 回答 2

1

为此使用ResXResourceReader 类

于 2012-09-06T09:28:17.730 回答
0
// Gets the value of associated with key "MyKey" from the local resource file for a given culture ("~/MyPage.aspx.en.resx") or from the default one ("~/MyPage.aspx.resx")
object keyValue = HttpContext.GetLocalResourceObject("~/MyPage.aspx", "MyKey", culture);

使用这样的东西

对于 Windows,此链接可能对您有用

http://www.c-sharpcorner.com/uploadfile/yougerthen/handle-resource-files-read-and-write-into-a-resx-file-programmatically-part-iii/

于 2012-09-06T09:34:01.520 回答