¡¡¡¡¡¡ÓÃc#¸øPDA×öÁËÒ»¸öPC¶ËµÄͨѶ³ÌÐò£¬ÐèÒª±£´æÁ½¸ö²ÎÊý¡£ÓÃDelphiʱ£¬ÊDZ£´æÔÚiniÎļþÖУ¬c#¶ÁдXML±È½Ï·½±ã£¬¾ÍÓÃxmlÎļþÀ´±£´æÁË¡£
¡¡¡¡¡¡
¡¡
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// ÏÂÔص½PDAµÄTXTÎļþ·¾¶¡¡
/// </summary>
public string strDownFile;
/// <summary>
/// PDAÊý¾ÝÎļþÉÏ´«µ½PC¶ËµÄÎļþ·¾¶
/// </summary>
public string strUploadFile;
public CXmlClass()
{
//Ö¸¶¨XMLÎļþÃû
XmlFilePath = "config.xml";
//¼ì²âXMLÅäÖÃÎļþÊÇ·ñ´æÔÚ
if (System.IO.File.Exists(XmlFilePath))
return;
CreateDefaultXml();
}
#region " ReadXML() ¶ÁÈ¡XMLÅäÖÃÎļþµÄ²ÎÊýÉèÖ㬻ñÈ¡ÏÂÔصÄTXTÎļþ·¾¶ÓëÉÏ´«µÄÊý¾ÝÎļþ·¾¶"
/// <summary>
/// ¶ÁÈ¡XMLÅäÖÃÎļþµÄ²ÎÊýÉèÖ㬻ñÈ¡ÏÂÔصÄTXTÎļþ·¾¶ÓëÉÏ´«µÄÊý¾ÝÎļþ·¾¶
/// </summary>
/// ......
¡¡¡¡¡¡ÓÃc#¸øPDA×öÁËÒ»¸öPC¶ËµÄͨѶ³ÌÐò£¬ÐèÒª±£´æÁ½¸ö²ÎÊý¡£ÓÃDelphiʱ£¬ÊDZ£´æÔÚiniÎļþÖУ¬c#¶ÁдXML±È½Ï·½±ã£¬¾ÍÓÃxmlÎļþÀ´±£´æÁË¡£
¡¡¡¡¡¡
¡¡
class CXmlClass
{
private string XmlFilePath;
/// <summary>
/// ÏÂÔص½PDAµÄTXTÎļþ·¾¶¡¡
/// </summary>
public string strDownFile;
/// <summary>
/// PDAÊý¾ÝÎļþÉÏ´«µ½PC¶ËµÄÎļþ·¾¶
/// </summary>
public string strUploadFile;
public CXmlClass()
{
//Ö¸¶¨XMLÎļþÃû
XmlFilePath = "config.xml";
//¼ì²âXMLÅäÖÃÎļþÊÇ·ñ´æÔÚ
if (System.IO.File.Exists(XmlFilePath))
return;
CreateDefaultXml();
}
#region " ReadXML() ¶ÁÈ¡XMLÅäÖÃÎļþµÄ²ÎÊýÉèÖ㬻ñÈ¡ÏÂÔصÄTXTÎļþ·¾¶ÓëÉÏ´«µÄÊý¾ÝÎļþ·¾¶"
/// <summary>
/// ¶ÁÈ¡XMLÅäÖÃÎļþµÄ²ÎÊýÉèÖ㬻ñÈ¡ÏÂÔصÄTXTÎļþ·¾¶ÓëÉÏ´«µÄÊý¾ÝÎļþ·¾¶
/// </summary>
/// ......
[System.Runtime.Serialization.DataMemberAttribute()]
public Information Archive {
get {
return this.archiveField;
}
set {
this.archiveField = value;
}
}
[System.Xml.Serialization.XmlAttributeAttribute()]
[System.Runtime.Serialization.DataMemberAttribu ......
[System.Runtime.Serialization.DataMemberAttribute()]
public Information Archive {
get {
return this.archiveField;
}
set {
this.archiveField = value;
}
}
[System.Xml.Serialization.XmlAttributeAttribute()]
[System.Runtime.Serialization.DataMemberAttribu ......
±ÈÈçÓÃÒ»¸öÀàÃèÊöÒ»ÕźÏͬ£¬¶øÕâ¸öÀàʵÀý»¯ºóÆäÖеÄ×ֶα£´æןÏͬµÄÐÅÏ¢£¬Èç¹ûÏÖÔÚÒª°ÑÕâ¸öÀàµÄʵÀý·¢Ë͵½Áíһ̨»úÆ÷¡¢ÁíÒ»¸ö´°Ìå»òÊÇÏë±£´æÕâ¸öÀàÒÔ±ãÒÔºóÔÙÈ¡³öÀ´Ó㨳־û¯¶ÔÏ󣩣¬¿ÉÒÔ¶ÔÕâ¸öÀà½øÐÐÐòÁл¯£¨ÐòÁл¯Êµ¼ÊÉÏÊÇÒ»¸öÐÅÏ¢Á÷£©£¬´«ËÍ»ò±£´æ£¬ÓõÄʱºòÔÙ·´ÐòÁл¯ÖØÐÂÉú³ÉÕâ¸ö¶ÔÏó
ΪʲôÄúÏëҪʹÓÃÐòÁл¯£¿ÓÐÁ½¸ö×îÖØÒªµÄÔÒò´Ùʹ¶ÔÐòÁл¯µÄʹÓãºÒ»¸öÔÒòÊǽ«¶ÔÏóµÄ״̬±£³ÖÔڴ洢ýÌåÖУ¬ÒÔ±ã¿ÉÒÔÔÚÒÔºóÖØд´½¨¾«È·µÄ¸±±¾£»ÁíÒ»¸öÔÒòÊÇͨ¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò·¢Ë͵½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£ÀýÈ磬ÐòÁл¯¿ÉÓÃÓÚÔÚ ASP.NET Öб£´æ»á»°×´Ì¬²¢½«¶ÔÏó¸´ÖƵ½ Windows ´°ÌåµÄ¼ôÌù°åÖС£Ô¶³Ì´¦Àí»¹¿ÉÒÔʹÓÃÐòÁл¯Í¨¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò´«µÝµ½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£
ÐòÁл¯µÄÊǶÔÏóµÄ״̬
Ò²¾ÍÊǶÔÏóÊý¾Ý³ÉÔ±µÄÖµºÍ·½·¨ÊÇûÓйØϵµÄ
¿çÓ¦ÓóÌÐòÓòͨÐÅʱ£¬ÒªÓõ½ÐòÁл¯
ÒÔ¼°ÓÃWEB·þÎñʱ
Ò»£ºBinaryFormatterÐòÁл¯
ÐòÁл¯¼òµ¥µãÀ´Àí½â¾ÍÊÇ°ÑÄÚ´æµÄ¶«Î÷дµ½Ó²ÅÌÖÐ, ......
±ÈÈçÓÃÒ»¸öÀàÃèÊöÒ»ÕźÏͬ£¬¶øÕâ¸öÀàʵÀý»¯ºóÆäÖеÄ×ֶα£´æןÏͬµÄÐÅÏ¢£¬Èç¹ûÏÖÔÚÒª°ÑÕâ¸öÀàµÄʵÀý·¢Ë͵½Áíһ̨»úÆ÷¡¢ÁíÒ»¸ö´°Ìå»òÊÇÏë±£´æÕâ¸öÀàÒÔ±ãÒÔºóÔÙÈ¡³öÀ´Ó㨳־û¯¶ÔÏ󣩣¬¿ÉÒÔ¶ÔÕâ¸öÀà½øÐÐÐòÁл¯£¨ÐòÁл¯Êµ¼ÊÉÏÊÇÒ»¸öÐÅÏ¢Á÷£©£¬´«ËÍ»ò±£´æ£¬ÓõÄʱºòÔÙ·´ÐòÁл¯ÖØÐÂÉú³ÉÕâ¸ö¶ÔÏó
ΪʲôÄúÏëҪʹÓÃÐòÁл¯£¿ÓÐÁ½¸ö×îÖØÒªµÄÔÒò´Ùʹ¶ÔÐòÁл¯µÄʹÓãºÒ»¸öÔÒòÊǽ«¶ÔÏóµÄ״̬±£³ÖÔڴ洢ýÌåÖУ¬ÒÔ±ã¿ÉÒÔÔÚÒÔºóÖØд´½¨¾«È·µÄ¸±±¾£»ÁíÒ»¸öÔÒòÊÇͨ¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò·¢Ë͵½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£ÀýÈ磬ÐòÁл¯¿ÉÓÃÓÚÔÚ ASP.NET Öб£´æ»á»°×´Ì¬²¢½«¶ÔÏó¸´ÖƵ½ Windows ´°ÌåµÄ¼ôÌù°åÖС£Ô¶³Ì´¦Àí»¹¿ÉÒÔʹÓÃÐòÁл¯Í¨¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò´«µÝµ½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£
ÐòÁл¯µÄÊǶÔÏóµÄ״̬
Ò²¾ÍÊǶÔÏóÊý¾Ý³ÉÔ±µÄÖµºÍ·½·¨ÊÇûÓйØϵµÄ
¿çÓ¦ÓóÌÐòÓòͨÐÅʱ£¬ÒªÓõ½ÐòÁл¯
ÒÔ¼°ÓÃWEB·þÎñʱ
Ò»£ºBinaryFormatterÐòÁл¯
ÐòÁл¯¼òµ¥µãÀ´Àí½â¾ÍÊÇ°ÑÄÚ´æµÄ¶«Î÷дµ½Ó²ÅÌÖÐ, ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//TransmitFileʵÏÖÏÂÔØ
protected void Button1_Click(object sender, EventArgs e)
{
/*
΢ÈíΪResponse¶ÔÏóÌṩÁËÒ»¸öеķ½·¨TransmitFileÀ´½â¾öʹÓÃResponse.BinaryWrite
ÏÂÔس¬¹ý400mbµÄÎļþʱµ¼ÖÂAspnet_wp.exe½ø³Ì»ØÊÕ¶øÎÞ·¨³É¹¦ÏÂÔصÄÎÊÌâ¡£
´úÂëÈçÏ£º
*/
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");
string filename = Server.MapPath("DownLoad/z.zip");
Response.TransmitFile(filename);
}
//WriteFileʵÏÖÏÂÔØ
protected void ......
using System;
using System.Data;
using System.Configuration;
using System.Web;
using System.Web.Security;
using System.Web.UI;
using System.Web.UI.WebControls;
using System.Web.UI.WebControls.WebParts;
using System.Web.UI.HtmlControls;
using System.IO;
public partial class _Default : System.Web.UI.Page
{
protected void Page_Load(object sender, EventArgs e)
{
}
//TransmitFileʵÏÖÏÂÔØ
protected void Button1_Click(object sender, EventArgs e)
{
/*
΢ÈíΪResponse¶ÔÏóÌṩÁËÒ»¸öеķ½·¨TransmitFileÀ´½â¾öʹÓÃResponse.BinaryWrite
ÏÂÔس¬¹ý400mbµÄÎļþʱµ¼ÖÂAspnet_wp.exe½ø³Ì»ØÊÕ¶øÎÞ·¨³É¹¦ÏÂÔصÄÎÊÌâ¡£
´úÂëÈçÏ£º
*/
Response.ContentType = "application/x-zip-compressed";
Response.AddHeader("Content-Disposition", "attachment;filename=z.zip");
string filename = Server.MapPath("DownLoad/z.zip");
Response.TransmitFile(filename);
}
//WriteFileʵÏÖÏÂÔØ
protected void ......
¾²Ì¬±äÁ¿
µ±ÎÒÃDZàдһ¸öÀàʱ£¬Æäʵ¾ÍÊÇÔÚÃèÊöÆä¶ÔÏóµÄÊôÐÔºÍÐÐΪ£¬¶ø²¢Ã»ÓвúÉúʵÖÊÉϵĶÔÏó£¬Ö»ÓÐͨ¹ýnew¹Ø¼ü×ֲŻá²úÉú³ö¶ÔÏó£¬Õâʱϵͳ²Å»á·ÖÅäÄÚ´æ¿Õ¼ä¸ø¶ÔÏó£¬Æä·½·¨²Å¿ÉÒÔ¹©Íⲿµ÷Óá£
ÓÐʱºò£¬ÎÒÃÇÏ£ÍûÎÞÂÛÊÇ·ñ²úÉúÁ˶ÔÏó»òÎÞÂÛ²úÉúÁ˶àÉÙ¶ÔÏóµÄÇé¿öÏ£¬Ä³Ð©Ìض¨µÄÊý¾ÝÔÚÄÚ´æ¿Õ¼äÀïÖ»ÓÐÒ»·Ý£¬ÀýÈçËùÓеÄÖйúÈ˶¼Óйú¼ÒÃû³Æ£¬Ã¿Ò»¸öÖйúÈ˶¼¹²ÏíÕâ¸ö¹ú¼ÒÃû³Æ£¬²»±ØÔÚÿһ¸öÖйúÈ˵ÄʵÀý¶ÔÏóÖж¼µ¥¶À·ÖÅäÒ»¸öÓÃÓÚ´úÂë¹ú¼ÒÃû³ÆµÄ±äÁ¿¡£Àý×Ó£º
protected void Page_Load(object sender, EventArgs e)
{
//Ö±½ÓʹÓÓÀàÃû.³ÉÔ±”µÄ¸ñʽ£¬²»ÄÜʹÓÓ¶ÔÏóÃû.³ÉÔ±”µÄ¸ñʽ£¬ÕâµãÓëJAVA²»Ò»Ñù£¬JAVAÁ½ÖÖ¶¼¿ÉÒÔʹÓÃ
Response.Write(Chinese.Country);
}
class Chinese
{
public static string Country = "Öйú";
public void getCountry()
{
&n ......
¾²Ì¬±äÁ¿
µ±ÎÒÃDZàдһ¸öÀàʱ£¬Æäʵ¾ÍÊÇÔÚÃèÊöÆä¶ÔÏóµÄÊôÐÔºÍÐÐΪ£¬¶ø²¢Ã»ÓвúÉúʵÖÊÉϵĶÔÏó£¬Ö»ÓÐͨ¹ýnew¹Ø¼ü×ֲŻá²úÉú³ö¶ÔÏó£¬Õâʱϵͳ²Å»á·ÖÅäÄÚ´æ¿Õ¼ä¸ø¶ÔÏó£¬Æä·½·¨²Å¿ÉÒÔ¹©Íⲿµ÷Óá£
ÓÐʱºò£¬ÎÒÃÇÏ£ÍûÎÞÂÛÊÇ·ñ²úÉúÁ˶ÔÏó»òÎÞÂÛ²úÉúÁ˶àÉÙ¶ÔÏóµÄÇé¿öÏ£¬Ä³Ð©Ìض¨µÄÊý¾ÝÔÚÄÚ´æ¿Õ¼äÀïÖ»ÓÐÒ»·Ý£¬ÀýÈçËùÓеÄÖйúÈ˶¼Óйú¼ÒÃû³Æ£¬Ã¿Ò»¸öÖйúÈ˶¼¹²ÏíÕâ¸ö¹ú¼ÒÃû³Æ£¬²»±ØÔÚÿһ¸öÖйúÈ˵ÄʵÀý¶ÔÏóÖж¼µ¥¶À·ÖÅäÒ»¸öÓÃÓÚ´úÂë¹ú¼ÒÃû³ÆµÄ±äÁ¿¡£Àý×Ó£º
protected void Page_Load(object sender, EventArgs e)
{
//Ö±½ÓʹÓÓÀàÃû.³ÉÔ±”µÄ¸ñʽ£¬²»ÄÜʹÓÓ¶ÔÏóÃû.³ÉÔ±”µÄ¸ñʽ£¬ÕâµãÓëJAVA²»Ò»Ñù£¬JAVAÁ½ÖÖ¶¼¿ÉÒÔʹÓÃ
Response.Write(Chinese.Country);
}
class Chinese
{
public static string Country = "Öйú";
public void getCountry()
{
&n ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Data;
namespace MyDbTest
{
class Program
{
static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(
@"Data Source=localhost;Initial Catalog=CSGL;Persist Security Info=True;User ID=test;Password=test");
thisConnection.Open();
SqlCommand myCommand = new SqlCommand("P_Test", thisConnection);
myCommand.CommandType = CommandType.StoredProcedure;
//Ìí¼ÓÊäÈë²éѯ²ÎÊý¡¢¸³ÓèÖµ
myCommand.Parameters.Add("@id", SqlDbType.Int);
myCommand.Parameters["@id"].Value = "120";
//Ìí¼ÓÊä³ö²ÎÊý
myCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
myCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
//µÃµ½´æ´¢¹ý³ÌÊä³ö²ÎÊý
Console.WriteLine(" ´æ´ ......
using System;
using System.Collections.Generic;
using System.Text;
using System.Data.SqlClient;
using System.Xml;
using System.Data;
namespace MyDbTest
{
class Program
{
static void Main(string[] args)
{
SqlConnection thisConnection = new SqlConnection(
@"Data Source=localhost;Initial Catalog=CSGL;Persist Security Info=True;User ID=test;Password=test");
thisConnection.Open();
SqlCommand myCommand = new SqlCommand("P_Test", thisConnection);
myCommand.CommandType = CommandType.StoredProcedure;
//Ìí¼ÓÊäÈë²éѯ²ÎÊý¡¢¸³ÓèÖµ
myCommand.Parameters.Add("@id", SqlDbType.Int);
myCommand.Parameters["@id"].Value = "120";
//Ìí¼ÓÊä³ö²ÎÊý
myCommand.Parameters.Add("@Rowcount", SqlDbType.Int);
myCommand.Parameters["@Rowcount"].Direction = ParameterDirection.Output;
myCommand.ExecuteNonQuery();
//µÃµ½´æ´¢¹ý³ÌÊä³ö²ÎÊý
Console.WriteLine(" ´æ´ ......