如何打开服务器上的文本文件 [英] How to open a text file situated at server

查看:190
本文介绍了如何打开服务器上的文本文件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

嗨 我的服务器中有一个文本文件.我需要打开.doc或.txt文件.如果您有任何想法,请建议我.我正在使用..
System.Diagnostics.Process.Start("PATH");

谢谢

Hi I have one text file in server. I need to open .doc or .txt file Please Suggest me if you have any ideas. I am using ..
System.Diagnostics.Process.Start("PATH");

Thanks

推荐答案

IIS Web服务器进程将作为服务在服务器上运行-不在服务器上本地登录的用户帐户中运行(实际上没有)甚至不需要成为登录用户)-几乎可以肯定不能与服务器桌面进行交互-但Process.Start将尝试启动登录用户通常会用来执行的应用程序(记事本,Word等)查看文件,几乎可以肯定会失败,因为它需要对其用户界面进行桌面访问.

如果您希望能够读取服务器上文件的内容,请使用System.IO文件功能(或流或..)或任何其他可以简单读取/解释相关类型文件的库. >
如果您希望Web用户能够在CLIENT机器上看到该文件,则需要传递一个Web响应,该响应的文件内容为HTTP响应-以及一个ContentType(MIME类型)来告诉用户''您的Web浏览器响应HTTP请求传送了什么样的数据,并且依赖于用户的浏览器能够在用户的计算机上找到合适的应用程序来打开/显示这种类型的内容.
IIS web server process will be running as a service on the server - NOT running in the locally logged on user account on the server (actually there doesn''t even need to be a user logegd on) - and almost certainly can''t interact with the server desktop - but Process.Start will try to start the application (Notepad, Word etc.) that a logged on user would normally use to view a file, which will almost certainly fail because it requires desktop access for its user interface.

If you want to be able to read the contents of the file on the server, use System.IO file functions (or streams or . . .) or any other libraries that can simply read / interpret files of the relevant type.

If you want your web user to be able to see the file on the CLIENT machine then you need to deliver a web response that has the contents of the file as the HTTP response - and a ContentType (Mime type) to tell the user''s web browser what sort of data you''re delivering in response to the HTTP request and rely on the user''s browser being able to find an appropriate application on the user''s machine to open / display that type of content.


我不确定您是否可以访问未设置为虚拟文件夹且未在IIS中授予权限的文件夹中的任何文件.
I''m not sure you can access any file in a folder that is not setup as a virtual folder and given permissions in IIS.


这篇关于如何打开服务器上的文本文件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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