Click here to Skip to main content
15,901,824 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
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
Posted
Updated 1-May-11 23:14pm
v2
Comments
thatraja 2-May-11 15:04pm    
Not clear, rephrase

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.
 
Share this answer
 
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.
 
Share this answer
 
Comments
NuttingCDEF 2-May-11 16:13pm    
Client side access to server files I agree entirely that you'll need IIS set up appropriately to get direct access.

I don't know what the ultimate constraints are server side, but in ASP.NET on Windows server I've certainly accessed (read and write) folders outside the web root on the server using physical drive paths server side / in ASP.NET server side code - you definitely need to make sure the Windows account the ASP.NET process is running in has appropriate Windows file access permissions (usual ACL permissions, nothing to do with IIS) to access the relevant files / folders, but subject to that I haven't yet hit any problems.

I've also implemented systems that use this to take request through a .aspx page and use request details to retrieve a file from outside the web root (and definitely not accessible direct by the client) and deliver them via the ASP.NET HTTP response.

We really need to know just what the questioner is trying to achieve.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900