slm
slm

Reputation: 11

Opening a file on IIS

I have a program which creates word, excel and powerpoint files. All my code works fine on client side. As automation of office tools is not possible on server side I used third party API's like Aspose and OfficeWriter to create the documents. I used below mentioned code to open, after creating the file.

string paths = Server.MapPath("~/Data/" + TextBox1.Text + ".docx" );
        Process prc = new Process();
        prc.StartInfo.FileName = paths;
        prc.Start();

This code will not open the file from IIS, even Aspose and OfficeWriter are meant to work on server. Then I tried to open .jpg file using this code on IIS. That also does not work. I think prs.start() will not work on IIS. Is there any alternative way to open the file. I dont want to open the file as if we are downloding an attachment.

Upvotes: 0

Views: 2192

Answers (1)

Oded
Oded

Reputation: 499012

Your code is trying to call the application associated with the .docx extension, wherever it is running.

If this is server side code, this is not likely to give you any useful results (assuming there is an association defined, the application pool identity running the site will now have this file opened. It can't do anything with it now).

You should probably be using Response.WriteFile - this will send the file to the client.

Upvotes: 2

Related Questions