-
usingSystem;
-
usingSystem.Drawing;
-
usingSystem.Collections;
-
usingSystem.ComponentModel;
-
usingSystem.Windows.Forms;
-
usingSystem.IO;
-
usingSystem.Xml;
-
namespaceMyWindows
-
{
-
///<summary>
-
-
-
-
-
-
-
-
-
-
-
-
publicclassForm1:System.Windows.Forms.Form
-
{
-
-
///<summary>
-
-
-
privateSystem.Windows.Forms.Buttonbutton1;
-
privateSystem.Windows.Forms.Buttonbutton2;
-
privateSystem.Windows.Forms.OpenFileDialogopenFileDialog1;
-
privateSystem.Windows.Forms.SaveFileDialogsaveFileDialog1;
-
privateSystem.Windows.Forms.Buttonbutton3;
-
privateSystem.Windows.Forms.Buttonbutton4;
-
privateSystem.Xml.XmlDocumentmXmlDoc;
-
privateSystem.Xml.XmlDocumentdoc;
-
privateSystem.ComponentModel.Containercomponents=null;
-
-
publicForm1()
-
{
-
-
-
-
InitializeComponent();
-
-
-
-
-
}
-
-
///<summary>
-
-
-
protectedoverridevoidDispose(booldisposing)
-
{
-
if(disposing)
-
{
-
if(components!=null)
-
{
-
components.Dispose();
-
}
-
}
-
base.Dispose(disposing);
-
}
-
-
Windows窗体设计器生成的代码#regionWindows窗体设计器生成的代码
-
///<summary>
-
-
-
-
privatevoidInitializeComponent()
-
{
-
this.button1=newSystem.Windows.Forms.Button();
-
this.button2=newSystem.Windows.Forms.Button();
-
this.openFileDialog1=newSystem.Windows.Forms.OpenFileDialog();
-
this.saveFileDialog1=newSystem.Windows.Forms.SaveFileDialog();
-
this.button3=newSystem.Windows.Forms.Button();
-
this.button4=newSystem.Windows.Forms.Button();
-
this.SuspendLayout();
-
-
-
-
this.button1.Location=newSystem.Drawing.Point(96,32);
-
this.button1.Name="button1";
-
this.button1.TabIndex=0;
-
this.button1.Text="生成xml";
-
this.button1.Click+=newSystem.EventHandler(this.button1_Click);
-
-
-
-
this.button2.Location=newSystem.Drawing.Point(96,80);
-
this.button2.Name="button2";
-
this.button2.TabIndex=1;
-
this.button2.Text="生成doc";
-
this.button2.Click+=newSystem.EventHandler(this.button2_Click);
-
-
-
-
this.button3.Location=newSystem.Drawing.Point(8,32);
-
this.button3.Name="button3";
-
this.button3.TabIndex=2;
-
this.button3.Text="加载doc";
-
this.button3.Click+=newSystem.EventHandler(this.button3_Click);
-
-
-
-
this.button4.Location=newSystem.Drawing.Point(8,80);
-
this.button4.Name="button4";
-
this.button4.TabIndex=3;
-
this.button4.Text="加载xml";
-
this.button4.Click+=newSystem.EventHandler(this.button4_Click);
-
-
-
-
this.AutoScaleBaseSize=newSystem.Drawing.Size(6,14);
-
this.ClientSize=newSystem.Drawing.Size(184,141);
-
this.Controls.Add(this.button4);
-
this.Controls.Add(this.button3);
-
this.Controls.Add(this.button2);
-
this.Controls.Add(this.button1);
-
this.Name="Form1";
-
this.Text="Form1";
-
this.ResumeLayout(false);
-
-
-
-
this.Load+=newSystem.EventHandler(this.Form1_Load);
-
this.Closed+=newSystem.EventHandler(this.Form1_Closed);
-
-
}
-
#endregion
-
-
///<summary>
-
-
-
staticvoidMain()
-
{
-
Application.Run(newForm1());
-
}
-
///<summary>
-
-
-
-
-
privatevoidbutton1_Click(objectsender,System.EventArgse)
-
{
-
saveFileDialog1.Filter="xml文件|*.xml";
-
saveFileDialog1.Title="保存成xml文件";
-
saveFileDialog1.FileName="";
-
saveFileDialog1.ShowDialog();
-
-
if(saveFileDialog1.FileName!="")
-
{
-
mXmlDoc.Save(saveFileDialog1.FileName);
-
MessageBox.Show("保存成功");
-
}
-
}
-
-
///<summary>
-
-
-
-
-
privatevoidbutton2_Click(objectsender,System.EventArgse)
-
{
-
-
XmlNodenode=doc.DocumentElement.SelectSingleNode("me");
-
XmlElementele=(XmlElement)node;
-
stringpic=ele.GetAttribute("aa");
-
-
byte[]bytes=Convert.FromBase64String(pic);
-
-
-
saveFileDialog1.Filter="OfficeDocuments(*.doc,*.xls,*.ppt)|*.doc;*.xls;*.ppt";
-
saveFileDialog1.Title="保存成office文件";
-
saveFileDialog1.FileName="";
-
saveFileDialog1.ShowDialog();
-
-
if(saveFileDialog1.FileName!="")
-
{
-
-
FileStreamoutfile=newSystem.IO.FileStream(saveFileDialog1.FileName,System.IO.FileMode.CreateNew);
-
outfile.Write(bytes,0,(int)bytes.Length);
-
MessageBox.Show("保存成功");
-
}
-
-
}
-
-
///<summary>
-
-
-
-
-
publicvoidForm1_Load(objectsender,System.EventArgse)
-
{
-
MessageBox.Show("欢迎使用蛙蛙牌文档转换器");
-
}
-
///<summary>
-
-
-
-
-
publicvoidForm1_Closed(objectsender,System.EventArgse)
-
{
-
mXmlDoc=null;
-
doc=null;
-
}
-
///<summary>
-
-
-
-
-
privatevoidbutton3_Click(objectsender,System.EventArgse)
-
{
-
stringstrFileName;
-
openFileDialog1.Filter="OfficeDocuments(*.doc,*.xls,*.ppt)|*.doc;*.xls;*.ppt";
-
openFileDialog1.FilterIndex=1;
-
openFileDialog1.FileName="";
-
openFileDialog1.ShowDialog();
-
strFileName=openFileDialog1.FileName;
-
if(strFileName.Length!=0)
-
{
-
System.IO.FileStreaminFile=newFileStream(strFileName,System.IO.FileMode.Open,System.IO.FileAccess.Read);
-
byte[]binaryData=newbyte[inFile.Length];
-
inFile.Read(binaryData,0,(int)inFile.Length);
-
stringmStr=Convert.ToBase64String(binaryData);
-
stringhh=mStr;
-
mXmlDoc=newSystem.Xml.XmlDocument();
-
-
mStr=string.Format("<wawa><meaa=\"{0}\"/></wawa>",mStr);
-
mXmlDoc.LoadXml(mStr);
-
MessageBox.Show("加载成功");
-
}
-
-
}
-
///<summary>
-
-
-
-
-
privatevoidbutton4_Click(objectsender,System.EventArgse)
-
{
-
stringstrFileName;
-
openFileDialog1.Filter="xml文件|*.xml";
-
openFileDialog1.FilterIndex=1;
-
openFileDialog1.FileName="";
-
openFileDialog1.ShowDialog();
-
strFileName=openFileDialog1.FileName;
-
-
if(strFileName.Length!=0)
-
{
-
doc=newXmlDocument();
-
doc.Load(strFileName);
-
MessageBox.Show("加载成功");
-
}
-
-
}
-
-
}
-
}
如果您对该产品感兴趣,请填写办理(客服微信:xiaoxiongyidong)
发表评论
◎欢迎参与讨论,请在这里发表您的看法、交流您的观点。