Click here to Skip to main content
15,886,919 members
Please Sign up or sign in to vote.
1.00/5 (1 vote)
See more:
byte[] Attachmnt;
Attachmnt = (byte[])dataGridView1.Rows[e.RowIndex].Cells["ResumeData"].Value;
Document1 objDoc = new Document1();           
objDoc.DocContent = Attachmnt;        
FileStream writeStream;
          
File.WriteAllBytes(Application.StartupPath+Resume, objDoc.DocContent);
//Next line is working for .doc extension
writeStream = new FileStream(Application.StartupPath + "Raaz.doc", FileMode.Create);
//Not Working for .pdf and .xps file
writeStream = new FileStream(Application.StartupPath + "File.pdf", FileMode.Create);
writeStream = new FileStream(Application.StartupPath + "Fil1.xps", FileMode.Create);
//In above two line i want help it should be save in pdf or xps file properly and open
//how can we do that user will select his file name with extension through //savefiledialog and then here it should be save as user given
BinaryWriter writeBinay = new BinaryWriter(writeStream);
writeBinay.Write(objDoc.DocContent);
writeBinay.Close();
writeStream.Close();
Posted
Comments
[no name] 17-Oct-12 7:30am    
And your question is what exactly?
StackQ 17-Oct-12 7:36am    
in this line when i m using extension-.pdf or .xps then file creates but when i m opening it manually showing error
writeStream = new FileStream(Application.StartupPath + "Raaz.pdf", FileMode.Create);

1 solution

You need a PDFwriter / xps writer to write it as PDF/XPS file.. you can't directly write the stream as pdf I am afraid.. please refer these links

http://www.dotnetspider.com/resources/5454-Create-text-to-pdf-c.aspx[^]


http://www.developerfusion.com/code/5682/create-pdf-files-on-fly-in-c/[^]
 
Share this answer
 

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