从ASP.net MVC 5解析文本文件 [英] Parse a text file from from ASP.net MVC 5
本文介绍了从ASP.net MVC 5解析文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我想从我的网页浏览器中保存一个网页,然后立即在我的MVC 5页面上运行一个脚本/方法,该页面以字符串形式读取,获取需要获取的内容并存入数据库,以及然后删除文件的内容。我会经常调用这个特定的脚本/方法,所以效率是必须的!
我可以弄清楚大部分内容,但很难找到用于读取文件的MVC文档。有什么指针吗?
提前感谢您帮助一个菜鸟!
I would like to save a webpage from my web browser and then run a script/method on it right away from my MVC 5 page which reads it in as a string, gets what it needs to get and deposits to database, and then deletes contents of the file. I will be calling this particular script/method frequently, so efficiency is a must!
I can figure out most of that, but the MVC documentation for reading in a file is hard to find. Any pointers?
Thanks in advance for helping a noob!
推荐答案
I我想说:MVC与阅读文件无关......
你问的是:
1)如何保存网站?
2)如何打开文本文件并解析数据?
广告1)
您应该使用 System.Net.HttpWebRequest [ ^ ]类下载站点而不是从浏览器保存它。将它保存到app_data文件夹。
我建议按照谢尔盖的答案 [ ^ ]。
广告2)
要打开文本文件,请参阅:在ASP.NET网页中读取文本文件 [ ^ ]
访问MVC app_data文件夹中的文件 [ ^ ]
我希望这部分信息足以开始。
I would like to say: "MVC has nothig to do with reading files"...
You are asking about:
1) how to save site?
2) how to open text file and parse data?
Ad 1)
You should use System.Net.HttpWebRequest[^] class to download the site instead saving it from browser. Save it to app_data folder.
I would suggest to follow the Sergey's answers[^] in this matter.
Ad 2)
To open text file, please see: Reading Text Files in an ASP.NET Web Page[^]
Accessing File in MVC app_data folder[^]
I hope this portion of information would be enough for start.
这篇关于从ASP.net MVC 5解析文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文