4
Answers

Crating word using winforms

Photo of rajesh kumar

rajesh kumar

7y
187
1
Hi everybody.,
    I am creating a winfroms application, my requirement is, when the user entered some data and submited , then it has to create a word file using word templete and it has to save. while saving vistor has to choose the path where that can download or saved. I tried by using sprice.doc but it was saving in bin directory.
My requirement user has to choose the path for saving that file please help me 

Answers (4)

0
Photo of Tapan Patel
NA 8.1k 101k 7y
Take a look at some of the documentation online for this class ( it is really necessary to go through these details to understand how it works).
 
Try below code (After you go through the details).
 
I have rich textbox with some content in it and a button (Save), on button click event, I am showing the dialog and if user opts to save it, it saves the content to appropriate file.
 
  1. private void button1_Click(object sender, EventArgs e)  
  2. {  
  3.     if (saveFile.ShowDialog()== DialogResult.OK)  
  4.     {  
  5.          File.WriteAllText(saveFile.FileName, richTextBox1.Text);  
  6.     }  
  7.       
  8. }  
 
Accepted
0
Photo of darjeam nh
NA 422 35 7y
see this article, it explains all what you want. You can specify the file path to any directory instead of bin folder.
 
 
http://www.c-sharpcorner.com/uploadfile/38268a/create-word-document-from-win-form-with-users-data/
0
Photo of rajesh kumar
NA 230 1.5k 7y
No, can please elobrate this. 
0
Photo of Tapan Patel
NA 8.1k 101k 7y
Did you try using SaveFileDialog ?