Home>
using system;
using system.collections.generic;
using system.componentmodel;
using system.data;
using system.drawing;
using system.text;
using system.windows.forms;
using system.reflection;
namespace demo
{
 public partial class form2:form
 {
  public form2 ()
  {
   initializecomponent ();
  }
  string path [email protected]"c:\ documents and settings \ administrator \ desktop \ output.doc";
  string add [email protected]"c:\ documents and settings \ administrator \ desktop \ file";
  private microsoft.office.interop.word.applicationclass applicationclass;
  private microsoft.office.interop.word.document doc;
  private void button1_click (object sender, eventargs e)
  {
   ex ();
  }
  void ex ()
  {
   open (path);
   string [] files=system.io.directory.getfiles (add);
   foreach (string s in files)
   {
    insertfile (s);
   }
   saveas (path);
  }
  ///<summary>
  ///open the output word document
  ///</summary>
  ///<param name="strfilename"></param>
  public void open (string strfilename)
  {
   applicationclass=new microsoft.office.interop.word.applicationclass ();
   object filename=strfilename;
   object readonly=false;
   object isvisible=true;
   object missing=system.reflection.missing.value;
   doc=applicationclass.documents.open (ref filename, ref missing, ref missing,   ref missing, ref missing, ref missing, ref missing, ref missing, ref missing,   ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
   doc.activate ();
  }
  ///<summary>
  ///insert word document into open word document
  ///</summary>
  ///<param name="strfilename"></param>
  public void insertfile (string strfilename)
  {
   object missing=system.reflection.missing.value;
   object confirmconversion=false;
   object link=false;
   object attachment=false;
   applicationclass.selection.insertfile (strfilename, ref missing, ref confirmconversion, ref link, ref attachment);
   object pbreak=(int) microsoft.office.interop.word.wdbreaktype.wdsectionbreaknextpage;
   applicationclass.selection.insertbreak (ref pbreak);
  }
  ///<summary>
  ///finally save the word document
  ///</summary>
  ///<param name="strfilename"></param>
  public void saveas (string strfilename)
  {
   object missing=system.reflection.missing.value;
   object filename=strfilename;
   doc.saveas (ref filename, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing, ref missing);
  }
 }
}
c
  • Previous Remote shutdown and restart using shutdown command
  • Next Explain in detail the sandbox mechanism and files during the iOS development process