阅读文本文件并将其写在网页上 [英] To read text file and write it on a webpage
本文介绍了阅读文本文件并将其写在网页上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
亲爱的朋友
我想上传我的项目文件夹中的文件以及数据库中的路径和日期。
然后我想阅读最新上传的文件,即基于日期或ID。
之后我必须在我的项目的网页上显示最新的文件内容。
我已经上传了我的项目文件夹中的文本文件,现在我想在MAX Id的基础上读取文件,并希望使用文字在网页上显示其内容。
请帮助我。
谢谢和问候
Akhilesh Pathak
Dear Friends
I want to upload files in my project folder and path and date in database.
And then I want to read latest uploaded file ie on the basis of Date or ID.
After that I have to display latest files content on a web page in my project.
I have uploaded the text files in my projects folder and now I want to read the file on the base of MAX Id and want to show its content on a web page by using literal.
Please help me.
Thanks and Regards
Akhilesh Pathak
推荐答案
这里需要基本元素:阅读一个文本文件并写一个。
要阅读文本文件,请使用:
You need to basic elements here: reading a text file and writing one.
To read a text file, use:
string FilePath;
FilePath = txtBoxInput.Text;
if (File.Exists(FilePath))
{
textBoxContents.Text = File.ReadAllText(FilePath);
}
要编写文本文件,请使用:
To write a text file, use:
DirectoryInfo Folder = new DirectoryInfo(textboxPath.Text);
if (Folder.Exists)
{
if (textboxName.Text != string.Empty)
{
string FilePathSave = Folder.ToString() + textboxName.Text;
File.WriteAllText(FilePathSave, textBoxContents.Text);
}
}
这篇关于阅读文本文件并将其写在网页上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!
查看全文