Ò׽ؽØͼÈí¼þ¡¢µ¥Îļþ¡¢Ãâ°²×°¡¢´¿ÂÌÉ«¡¢½ö160KB

C#»ñÈ¡µ±Ç°Â·¾¶µÄ·½·¨

//»ñÈ¡°üº¬Çåµ¥µÄÒѼÓÔØÎļþµÄ·¾¶»ò UNC λÖá£
public static string sApplicationPath = Assembly.GetExecutingAssembly ( ).Location;
//result: X:\xxx\xxx\xxx.dll (.dllÎļþËùÔÚµÄĿ¼+.dllÎļþÃû)
//»ñÈ¡µ±Ç°½ø³ÌµÄÍêÕû·¾¶£¬°üº¬ÎļþÃû(½ø³ÌÃû)¡£
string str = this.GetType ( ).Assembly.Location;
//result: X:\xxx\xxx\xxx.exe (.exeÎļþËùÔÚµÄĿ¼+.exeÎļþÃû)
//»ñÈ¡Ð嵀 Process ×é¼þ²¢½«ÆäÓ뵱ǰ»î¶¯µÄ½ø³Ì¹ØÁªµÄÖ÷Ä£¿éµÄÍêÕû·¾¶£¬°üº¬ÎļþÃû(½ø³ÌÃû)¡£
string str = System.Diagnostics.Process.GetCurrentProcess ( ).MainModule.FileName;
//result: X:\xxx\xxx\xxx.exe (.exeÎļþËùÔÚµÄĿ¼+.exeÎļþÃû)
//»ñÈ¡ºÍÉèÖõ±Ç°Ä¿Â¼£¨¼´¸Ã½ø³Ì´ÓÖÐÆô¶¯µÄĿ¼£©µÄÍêÈ«ÏÞ¶¨Â·¾¶¡£
string str = System.Environment.CurrentDirectory;
//result: X:\xxx\xxx (.exeÎļþËùÔÚµÄĿ¼)
//»ñÈ¡µ±Ç° Thread µÄµ±Ç°Ó¦ÓóÌÐòÓòµÄ»ùĿ¼£¬ËüÓɳÌÐò¼¯³åÍ»½â¾ö³ÌÐòÓÃÀ´Ì½²â³ÌÐò¼¯¡£
string str = System.AppDomain.CurrentDomain.BaseDirectory;
//result: X:\xxx\xxx\ (.exeÎļþËùÔÚµÄĿ¼+"\")
//»ñÈ¡ºÍÉèÖðüº¬¸ÃÓ¦ÓóÌÐòµÄĿ¼µÄÃû³Æ¡£
string str = System.AppDomain.CurrentDomain.SetupInformation.ApplicationBase;
//result: X:\xxx\xxx\ (.exeÎļþËùÔÚµÄĿ¼+"\")
//»ñÈ¡Æô¶¯ÁËÓ¦ÓóÌÐòµÄ¿ÉÖ´ÐÐÎļþµÄ·¾¶£¬²»°üÀ¨¿ÉÖ´ÐÐÎļþµÄÃû³Æ¡£
string str = System.Windows.Forms.Application.StartupPath;
//result: X:\xxx\xxx (.exeÎļþËùÔÚµÄĿ¼)
//»ñÈ¡Æô¶¯ÁËÓ¦ÓóÌÐòµÄ¿ÉÖ´ÐÐÎļþµÄ·¾¶£¬°üÀ¨¿ÉÖ´ÐÐÎļþµÄÃû³Æ¡£
string str = System.Windows.Forms.Application.ExecutablePath;
//result: X:\xxx\xxx\xxx.exe (.exeÎļþËùÔÚµÄĿ¼+.exeÎļþÃû)
//»ñÈ¡Ó¦ÓóÌÐòµÄµ±Ç°¹¤×÷Ŀ¼(²»¿É¿¿)¡£
string str = System.IO.Directory.GetCurrentDirectory ( );
//result: X:\xxx\xxx (.exeÎļþËùÔÚµÄĿ¼)
//ÔÚϵͳ·þÎñÖÐ×îºÃÓÃÕâ¸ö·½Ê½È¥È¡Â·¾¶
string stmp = Assembly.GetExecutingAssembly ( ).Location;
stmp = stmp.Substring ( 0 , stmp.LastIndexOf ( '\\' ) );//ɾ³ýÎļþÃû
if ( pathType == 1 )
return stmp + @"\inputLog.xml";
else if ( pathType == 2 )
return stmp + @"\MiddleDB.xml";
else
return stmp + @"\AppNo.xml";
using System.IO;
string path = "d:asdfasdf.bmp";
string fileNam


Ïà¹ØÎĵµ£º

asp.net(c#) ÏÂSQL´æ´¢¹ý³ÌʹÓÃÏêϸʵÀý

¼ÇÈ¡¼Ç¼¼¯
create procedure getArticle
as
select * from Article_Content
GO
asp.net µ÷Ó÷½·¨
  SqlConnection Conn = new SqlConnection();
        Conn.ConnectionString = Data.Connstr();
        Conn.Open();
  ......

C#ÀûÓÃwebrequest¼ÆËã´ýÏÂÔصÄÎļþ´óС

C#ÀûÓÃwebrequest¼ÆËã´ýÏÂÔصÄÎļþ´óС
string URL = textBox1.Text;
string filetype = URL.Substring(URL.LastIndexOf(".") + 1, (URL.Length - URL.LastIndexOf(".") - 1));
filetypevalue.Text = filetype.ToUpper();
string filename = URL.Substring(URL.LastIn ......

GDI+ÈëÃÅ(C#¸ßËÙ´¦Àí°æ±¾)

Ê×ÏȸÐлCSDNµÄÅóÓÑlaviewpbtΪÎÒ¸øÎҵĽ¨Òé¡£
laviewpbtÌá³öʹÓÃgetpixel´¦ÀíËÙ¶ÈÌ«Âý£¬Éϲ»Á˵µ´Î¡£
ÕâÀïÎÒÔÙ¸ø´ó¼ÒдÁ½ÖÖ´¦ÀíËٶȸü¿ìµÄͼÐδ¦Àí·½Ê½¡£
ÏÂÃæÊǸöÄÚ´æ²Ù×÷»Ò¶ÈµÄ³ÌÐò£º
bmp = new Bitmap(Application.StartupPath + "\\1.jpg");
            ......

ÔÚC#.netÖÐÈçºÎ²Ù×÷XML


ÔÚC#.netÖÐÈçºÎ²Ù×÷XML
¿ÉÄܺܶàÅóÓÑ»¹Ã»ÓнøÐйýXML²Ù×÷,Ï£ÍûÏÂÃæÕâƪÎÄÕÂÄܶԴó¼ÒÓаïÖú.»òÕß×Ô¼º¸´ÖÆһϴúÂëÊÔÒ»ÏÂ.ÕâƪÎÄÕ²»ÊÇÎÒдµÄ.ÎÒÖ»ÊÇת¹ýÀ´.¾õµÃ²»´í.
ÐèÒªÌí¼ÓµÄÃüÃû¿Õ¼ä£º
using System.Xml;
¶¨Ò弸¸ö¹«¹²¶ÔÏó£º
XmlDocument xmldoc ;
XmlNode xmlnode ;
XmlElement xmlelem ;
1£¬´´½¨µ½·þÎñÆ÷ͬà ......
© 2009 ej38.com All Rights Reserved. ¹ØÓÚE½¡ÍøÁªÏµÎÒÃÇ | Õ¾µãµØͼ | ¸ÓICP±¸09004571ºÅ