Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB
ÈÈÃűêÇ©£º c c# c++ asp asp.net linux php jsp java vb Python Ruby mysql sql access Sqlite sqlserver delphi javascript Oracle ajax wap mssql html css flash flex dreamweaver xml
 ×îÐÂÎÄÕ : c#

c# ¶ÁдXMLÎļþ

¡¡¡¡¡¡ÓÃ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# ¶ÁдXMLÎļþ

¡¡¡¡¡¡ÓÃ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# XmlÖÐÓ³ÉäΪÀàÊý¾Ý½á¹¹£¨±¨ÎÄ£©

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
                return this.archiveField;
            }
            set {
                    this.archiveField = value;
            }
        }
        
        [System.Xml.Serialization.XmlAttributeAttribute()]
        [System.Runtime.Serialization.DataMemberAttribu ......

C# XmlÖÐÓ³ÉäΪÀàÊý¾Ý½á¹¹£¨±¨ÎÄ£©

        [System.Runtime.Serialization.DataMemberAttribute()]
        public Information Archive {
            get {
                return this.archiveField;
            }
            set {
                    this.archiveField = value;
            }
        }
        
        [System.Xml.Serialization.XmlAttributeAttribute()]
        [System.Runtime.Serialization.DataMemberAttribu ......

"ÐòÁл¯" Serializable Àí½â (asp.net C#)

 ±ÈÈçÓÃÒ»¸öÀàÃèÊöÒ»ÕźÏͬ£¬¶øÕâ¸öÀàʵÀý»¯ºóÆäÖеÄ×ֶα£´æןÏͬµÄÐÅÏ¢£¬Èç¹ûÏÖÔÚÒª°ÑÕâ¸öÀàµÄʵÀý·¢Ë͵½Áíһ̨»úÆ÷¡¢ÁíÒ»¸ö´°Ìå»òÊÇÏë±£´æÕâ¸öÀàÒÔ±ãÒÔºóÔÙÈ¡³öÀ´Ó㨳־û¯¶ÔÏ󣩣¬¿ÉÒÔ¶ÔÕâ¸öÀà½øÐÐÐòÁл¯£¨ÐòÁл¯Êµ¼ÊÉÏÊÇÒ»¸öÐÅÏ¢Á÷£©£¬´«ËÍ»ò±£´æ£¬ÓõÄʱºòÔÙ·´ÐòÁл¯ÖØÐÂÉú³ÉÕâ¸ö¶ÔÏó
ΪʲôÄúÏëҪʹÓÃÐòÁл¯£¿ÓÐÁ½¸ö×îÖØÒªµÄÔ­Òò´Ùʹ¶ÔÐòÁл¯µÄʹÓãºÒ»¸öÔ­ÒòÊǽ«¶ÔÏóµÄ״̬±£³ÖÔڴ洢ýÌåÖУ¬ÒÔ±ã¿ÉÒÔÔÚÒÔºóÖØд´½¨¾«È·µÄ¸±±¾£»ÁíÒ»¸öÔ­ÒòÊÇͨ¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò·¢Ë͵½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£ÀýÈ磬ÐòÁл¯¿ÉÓÃÓÚÔÚ    ASP.NET    Öб£´æ»á»°×´Ì¬²¢½«¶ÔÏó¸´ÖƵ½    Windows    ´°ÌåµÄ¼ôÌù°åÖС£Ô¶³Ì´¦Àí»¹¿ÉÒÔʹÓÃÐòÁл¯Í¨¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò´«µÝµ½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£  
   
   ÐòÁл¯µÄÊǶÔÏóµÄ״̬  
   Ò²¾ÍÊǶÔÏóÊý¾Ý³ÉÔ±µÄÖµºÍ·½·¨ÊÇûÓйØϵµÄ
¿çÓ¦ÓóÌÐòÓòͨÐÅʱ£¬ÒªÓõ½ÐòÁл¯  
   ÒÔ¼°ÓÃWEB·þÎñʱ
Ò»£ºBinaryFormatterÐòÁл¯
ÐòÁл¯¼òµ¥µãÀ´Àí½â¾ÍÊÇ°ÑÄÚ´æµÄ¶«Î÷дµ½Ó²ÅÌÖÐ, ......

"ÐòÁл¯" Serializable Àí½â (asp.net C#)

 ±ÈÈçÓÃÒ»¸öÀàÃèÊöÒ»ÕźÏͬ£¬¶øÕâ¸öÀàʵÀý»¯ºóÆäÖеÄ×ֶα£´æןÏͬµÄÐÅÏ¢£¬Èç¹ûÏÖÔÚÒª°ÑÕâ¸öÀàµÄʵÀý·¢Ë͵½Áíһ̨»úÆ÷¡¢ÁíÒ»¸ö´°Ìå»òÊÇÏë±£´æÕâ¸öÀàÒÔ±ãÒÔºóÔÙÈ¡³öÀ´Ó㨳־û¯¶ÔÏ󣩣¬¿ÉÒÔ¶ÔÕâ¸öÀà½øÐÐÐòÁл¯£¨ÐòÁл¯Êµ¼ÊÉÏÊÇÒ»¸öÐÅÏ¢Á÷£©£¬´«ËÍ»ò±£´æ£¬ÓõÄʱºòÔÙ·´ÐòÁл¯ÖØÐÂÉú³ÉÕâ¸ö¶ÔÏó
ΪʲôÄúÏëҪʹÓÃÐòÁл¯£¿ÓÐÁ½¸ö×îÖØÒªµÄÔ­Òò´Ùʹ¶ÔÐòÁл¯µÄʹÓãºÒ»¸öÔ­ÒòÊǽ«¶ÔÏóµÄ״̬±£³ÖÔڴ洢ýÌåÖУ¬ÒÔ±ã¿ÉÒÔÔÚÒÔºóÖØд´½¨¾«È·µÄ¸±±¾£»ÁíÒ»¸öÔ­ÒòÊÇͨ¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò·¢Ë͵½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£ÀýÈ磬ÐòÁл¯¿ÉÓÃÓÚÔÚ    ASP.NET    Öб£´æ»á»°×´Ì¬²¢½«¶ÔÏó¸´ÖƵ½    Windows    ´°ÌåµÄ¼ôÌù°åÖС£Ô¶³Ì´¦Àí»¹¿ÉÒÔʹÓÃÐòÁл¯Í¨¹ýÖµ½«¶ÔÏó´ÓÒ»¸öÓ¦ÓóÌÐòÓò´«µÝµ½ÁíÒ»¸öÓ¦ÓóÌÐòÓòÖС£  
   
   ÐòÁл¯µÄÊǶÔÏóµÄ״̬  
   Ò²¾ÍÊǶÔÏóÊý¾Ý³ÉÔ±µÄÖµºÍ·½·¨ÊÇûÓйØϵµÄ
¿çÓ¦ÓóÌÐòÓòͨÐÅʱ£¬ÒªÓõ½ÐòÁл¯  
   ÒÔ¼°ÓÃWEB·þÎñʱ
Ò»£ºBinaryFormatterÐòÁл¯
ÐòÁл¯¼òµ¥µãÀ´Àí½â¾ÍÊÇ°ÑÄÚ´æµÄ¶«Î÷дµ½Ó²ÅÌÖÐ, ......

ÓÃC#(ASP.NET)ÔõôʵÏÖÎļþÏÂÔع¦ÄÜ

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 ......

ÓÃC#(ASP.NET)ÔõôʵÏÖÎļþÏÂÔع¦ÄÜ

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 ......

asp.net(c#) static¹Ø¼ü×ÖÓ÷¨Ð¡½á

¾²Ì¬±äÁ¿
       µ±ÎÒÃ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 ......

asp.net(c#) static¹Ø¼ü×ÖÓ÷¨Ð¡½á

¾²Ì¬±äÁ¿
       µ±ÎÒÃ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 ......

C#²Ù×÷¸÷ÖÖÖ´ÐÐsqlµÄ·½·¨º¬´æ´¢¹ý³Ì²Ù×÷

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(" ´æ´ ......

C#²Ù×÷¸÷ÖÖÖ´ÐÐsqlµÄ·½·¨º¬´æ´¢¹ý³Ì²Ù×÷

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(" ´æ´ ......
×ܼǼÊý:642; ×ÜÒ³Êý:107; ÿҳ6 Ìõ; Ê×Ò³ ÉÏÒ»Ò³ [23] [24] [25] [26] 27 [28] [29] [30] [31] [32]  ÏÂÒ»Ò³ βҳ
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ