从文件发布数据表

时间:2019-05-03 03:08:02

标签: c# datatable

enter image description here我有一个任务来读取和修改resx文件中的数据,现在我正尝试使用POST方法将数据插入到我的数据表中,但是我现在不知道,有人可以帮助我请?

    [HttpGet]
    public ActionResult Index()
    {
        string lines = "";
        string curFile = "E:\\App_GlobalResources\\GlobalResource" + ".resx";

        lines = System.IO.File.ReadAllText(curFile);
        lines = Xoa(lines, @"<!--", @"/resheader>");
        var ds = new DataSet();
        using (var reader = new StringReader(lines))
        {
            ds.ReadXml(reader);
        }
        DataTable tbl = ds.Tables[0];
        return View(tbl);
    }
   [HttpPost]
   public ActionResult Index()
   {
   }
    public static string Xoa(string lines, string strStart, string strEnd)
    {
        int Start, End;
        if (lines.Contains(strStart) && lines.Contains(strEnd))
        {
            Start = lines.IndexOf(strStart);
            End = lines.LastIndexOf(strEnd) + strEnd.Length;
            return lines.Remove(Start, End - Start);
        }
        else
        {
            return "";
        }

0 个答案:

没有答案