首页 文章

访问和读取多个* .resx文件中的数据

提问于
浏览
0

我是C#.NET的新手 .

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

首先,一旦我给了该文件夹的路径,就会在那里找到文件,但现在,我如何读取这些文件并将数据从它们获取到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.");
        }
    }

非常感谢 .

2 回答

  • 0

    使用ResXResourceReader Class为此 .

  • 1
    // 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/

相关问题