如何使用C#从计算机读取文件

编程入门 行业动态 更新时间:2024-10-25 06:30:12
本文介绍了如何使用C#从计算机读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述

朋友, 单击浏览按钮时,我有一个浏览按钮,它正在搜索 计算机中的文件,如果我按OK,则必须读取它.但无法读取.我应该在控制器和视图中编写什么代码.我用过 fileReader和StreamReader方法.我应该怎么做 朋友,我正在使用asp mvc 3 Web应用程序,请告诉我有关此信息 迫切的 请提供其他替代方法来纠正我的问题 谢谢大家

hi friends, I have an browse button when clicking on that browse button it is searching for files in the computer and if i press ok then it has to be read.but the reading is not possible.What code should i suppose to write in the controller and view.I have used fileReader and StreamReader methods.what should i suppose to do Friends i am using asp mvc 3 web application please tell me regarding this its urgent please provide any alternative ways to rectify my problem Thank you all

推荐答案

导入IO名称空间 import IO namespace using System.IO;

使用以下代码读取文件的所有内容

use below code read all content of a file

StreamReader objReader=new StreamReader(fullFilePath); string fileContent=objReader.ReadToEnd(); objReader.Close();

祝您好运Priya!

Best of luck Priya!

嗨Priya0143, 请参考此链接如何:从文本文件读取(C#编程指南) [ ^ ] Hi Priya0143, Please refer this link How to: Read From a Text File (C# Programming Guide)[^]

您好, 试试这个 字符串s = System.IO.File.ReadAllText(path); 请参阅此链接 stackoverflow/questions/8939640/how-to-read-a-doc-and-docx-file-in-asp-net-mvc3-and-display-in-textbox [ ^ ] 希望对您有帮助 祝你好运 快乐编码:) Hi, try this string s = System.IO.File.ReadAllText( path ); refer this link stackoverflow/questions/8939640/how-to-read-a-doc-and-docx-file-in-asp-net-mvc3-and-display-in-textbox[^] hope it help u best Luck Happy Coding:)

更多推荐

如何使用C#从计算机读取文件

本文发布于:2023-11-02 13:47:37,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1552561.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:如何使用   计算机   文件

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!