如何使用C#从计算机读取文件 [英] How to read a file from computer using c#

查看:67
本文介绍了如何使用C#从计算机读取文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

朋友,

单击浏览按钮时,我有一个浏览按钮,它正在搜索
计算机中的文件,如果我按OK,则必须读取它.但无法读取.我应该在控制器和视图中编写什么代码.我用过
fileReader和StreamReader方法.我应该怎么做

朋友,我正在使用asp.net 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.net 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);
请参阅此链接 ^ ]
希望对您有帮助
祝你好运
快乐编码:)
Hi,

try this
string s = System.IO.File.ReadAllText( path );
refer this link http://stackoverflow.com/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#从计算机读取文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆