随笔分类 - C#
摘要:public static void Serialize(T entity) { TextWriter tw = new StringWriter(); var formatter = new XmlSerializer(typeof(T)); formatter.Serialize(tw, entity); if (!Directory.Exists(Path.GetDirectoryName(Filename))) { Director...
阅读全文
摘要:using System;using System.Collections.Generic;using System.Linq;using System.Text;using Microsoft.Win32;namespace AirPatientForm{ class RegistryDAO { public static string GetRegistData(string name) { if (!IsRegeditExit(name)) { CreateRegedit(@...
阅读全文
摘要:using System;using System.Collections.Generic;using System.ComponentModel;using System.Data;using System.Drawing;using System.Linq;using System.Text;using System.Windows.Forms;using AirPatientForm;using AirwayCT.Entity;namespace BuildPatients{ public partial class Form1 : Form { public ...
阅读全文
摘要:http://msdn.microsoft.com/zh-cn/library/system.io.ports.serialport(VS.80).aspx
阅读全文
摘要:https://km.zebra.com/kb/index?page=forums&topic=02147b7d6f1f013241a33e9c007c30http://nicholas.piasecki.name/blog/2009/03/sending-raw-epl2-directly-to-a-zebra-lp2844-via-c/
阅读全文
摘要:PrintDocument printDocument = new PrintDocument(); printDocument.OriginAtMargins = true; printDocument.PrinterSettings.PrinterName = _PrinterName;printDocument.DefaultPageSettings.PaperSize = new System.Drawing.Printing.PaperSize("SpecimenLabel", 110, 180);//页面大小 printDocument.DefaultPag..
阅读全文
摘要:public static Bitmap GetThumbnail(Bitmap b, int destHeight, int destWidth) { System.Drawing.Image imgSource = b; System.Drawing.Imaging.ImageFormat thisFormat = imgSource.RawFormat; int sW = 0, sH = 0; // 按比例缩放 ...
阅读全文
摘要:http://www.c-sharpcorner.com/UploadFile/krishnasarala/barcode-scanner-in-C-Sharp/
阅读全文
摘要:http://blog.sina.com.cn/s/blog_7fd9438d0100yxj6.html
阅读全文
摘要:WebClient webClient = new WebClient(); webClient.Credentials = new NetworkCredential("username", "password"); webClient.Credentials = CredentialCache.DefaultCredentials; XmlTextReader que = new XmlTextReader(webClient.OpenRead(new Uri(filePath, ...
阅读全文
摘要:/// <summary> /// 判断是否是非法字符 /// </summary> /// <param name="str">判断是字符</param> /// <returns></returns> protected static Boolean isLegalNumber(string str) { char[] charStr = str.ToLower().ToCharArray(); if (charStr[0] == '0') ...
阅读全文
摘要:XmlSerializer ser = new XmlSerializer(typeof(Report));if (Directory.Exists("c:\\工作报告\\" + report.toBoss + "\\" + report.name)){ string filename = date.Text; string filepath = "c:\\工作报告\\" + report.toBoss + "\\" + report.name + "\\" + filename + "
阅读全文
摘要:流用于对IO处理 在System.IO名称空间中有以下类 BinaryReader/Writer TextReader/Writer Stream 其中类Stream为抽象类。由此有三个派生类: MemoryStream:对内存进行读取与写入 BufferedStream:对缓冲器进行读取/写入 FileStream:对文件执行读取与写入 TextReader/Writer为抽象类。由此派生类: StreamReader/StreamWirter StringReader/StreamWriter 需要引入命名空间: using System.IO 内存流与缓冲的使用举例: MemoryStr
阅读全文
摘要:using System;using System.Net;using System.Net.Sockets;using System.Text;using System.Threading;// State object for reading client data asynchronouslypublic class StateObject{ // Client socket. public Socket workSocket = null; // Size of receive buffer. public const int BufferSize = 102...
阅读全文
摘要:using System;using System.Net;using System.Net.Sockets;using System.Threading;using System.Text;// State object for receiving data from remote device.public class StateObject{ // Client socket. public Socket workSocket = null; // Size of receive buffer. public const int BufferSize = 256;...
阅读全文
摘要:AsyncServer: Bind - Listen - BeginAccept - EndAccept - BeginReceive - EndReceive - BeginSend - EndSend - Shutdown - CloseAcceptCallbackReadCallbackSendCallbackAsyncClient: BeginConnect - EndConnect -BeginSend - EndSend - BeginReceive - EndReceive- Shutdown - Close ConnectCallbackSendCallback Receive
阅读全文
摘要:BackgroundWorker connectWork = new BackgroundWorker(); public FormClient(){ connectWork.DoWork += new DoWorkEventHandler(connectWork_DoWork); connectWork.RunWorkerCompleted += new RunWorkerCompletedEventHandler(connectWork_RunWorkerCompleted);} /// <summary> /// 异步方式与服务器进行连接 ...
阅读全文
摘要:User:using System;using System.Collections.Generic;using System.Linq;using System.Text;using System.Net.Sockets;using System.IO;namespace AsyncTcpServer{ class User { public TcpClient client { get; private set; } public BinaryReader br { get; private set; } public BinaryWr...
阅读全文
摘要:服务器端:namespace SocketTest{ class Program { public static void SendMessage() { Socket socket = serverSocket.Accept(); Console.WriteLine("Connected a client:{0}",socket.RemoteEndPoint); socket.Send(Encoding.ASCII.GetBytes("welcome to server"));...
阅读全文
摘要:由于线程安全问题,在多线程编程下更改一个控件的属性时,往往需要用托管来更改属性的值.下面是一个通用的托管,用反射来对属性进行赋值.public delegate void SetValueCallBack(Control control, string property, object value);public static void SetValue(Control control, string property, object value)...{ if (control.InvokeRequired) control.Invoke(new SetValueCa...
阅读全文

浙公网安备 33010602011771号