winforms - How to troubleshoot error while opening downloaded pdf file in C#? Windows Application -


in windows application, have pdf file stored in database. problem is, when try open pdf file, error

adobe reader not open 'tem1.pdf' because either not supported file type or because file has been damaged

but when open downloaded pdf normally, not give error. getting error when try open them through application.

the code try open pdf files stored in database follows:

private void lstbookparts_selectedindexchanged(object sender, eventargs e) {         if (lstbookparts.selecteditems.count > 0)         {             wicommonfunction.loadcommonsettings();             showinformation showdata = new showinformation();             string item = lstbookparts.selecteditems[0].text;             string book = bookname;             calculatecount(book);             dataset ds1 = showdata.showbookpdf(item);             datatable dt1 = ds1.tables[0];             filestream fs = null;             var index = lstbookparts.selectedindices;             int32 = (int32)(index[0]);             byte[] bytes = (byte[])(dt1.rows[i]["content"]);             string filepath = "d:\\temp1.pdf";             fs = new filestream(filepath, system.io.filemode.create);             fs.write(bytes, 0, bytes.length);             fs.close();             process proc = new process();             proc.startinfo.filename = filepath;             proc.start();         } } 

by using code pdf files open properly, others giving error.

how can solve problem? there need make changes in code?

please suggest me solution this.

thanks in advance.

try process.start

 system.diagnostics.process.start("acrord32.exe", "d:/kyc.pdf"); 

to open pdf file.make sure pdf reader installed in machine.

reference link


Comments

Popular posts from this blog

curl - PHP fsockopen help required -

HTTP/1.0 407 Proxy Authentication Required PHP -

c# - Resource not found error -