//
得到路徑
????????????
string
?strPath
=
System.IO.Directory.GetCurrentDirectory();
//
分割
string
?str1
=
"
text1,text2,text3,text4
"
string
[]?stri
=
str1.Split(
new
?
char
[]
{
'
,
'
}
);

//
啟動一個程序
using
?System;
using
?System.Drawing;
using
?System.Collections;
using
?System.ComponentModel;
using
?System.Windows.Forms;
using
?System.Data;
using
?System.Diagnostics;
using
?System.Reflection;
using
?System.Runtime.InteropServices;


????????
/**/
///
?
<summary>
????????
///
?應用程序的主入口點。
????????
///
?
</summary>
????????[STAThread]
????????
static
?
void
?Main()?

????????
{
????????????
//
Get?the?running?instance.
????????????Process?instance?
=
?RunningInstance();
????????????
if
?(instance?
==
?
null
)

????????????
{
????????????????
//
新實例
????????????????Application.Run(
new
?Form1());
????????????}
????????????
else
????????????
{
????????????????
//
相同的實例,并將窗口置前
????????????????HandleRunningInstance(instance);
????????}
????}
public
?
static
?Process?RunningInstance()

{
????Process?current?
=
?Process.GetCurrentProcess();
????Process[]?processes?
=
?Process.GetProcessesByName?(current.ProcessName);
????
//
查找相同名的進程
????
foreach
?(Process?process?
in
?processes)

????
{
????
//
忽略當前線程
????
if
?(process.Id?
!=
?current.Id)

????
{
????
//
確認相同名的進程運行位置是否相同
????
if
?(Assembly.GetExecutingAssembly().Location.Replace(
"
/
"
,?
"
\\
"
)?
==
current.MainModule.FileName)

{
????
//
返回相同名進程
????
return
?process;
}
}
}
????
//
沒有其它進程,返回空值
????
return
?
null
;
}
?
public
?
static
?
void
?HandleRunningInstance(Process?instance)

?
{
?
//
確認窗口是最小化或最大化
?ShowWindowAsync?(instance.MainWindowHandle?,?WS_SHOWNORMAL);

?
//
將窗口置前
?SetForegroundWindow?(instance.MainWindowHandle);
?}
?[DllImport(
"
User32.dll
"
)]?

private
?
static
?
extern
?
bool
?ShowWindowAsync(IntPtr?hWnd,?
int
?cmdShow);
?[DllImport(
"
User32.dll
"
)]?
private
?
static
?
extern
?
bool
?SetForegroundWindow(IntPtr?hWnd);
?
private
?
const
?
int
?WS_SHOWNORMAL?
=
?
1
;

????????
private
?
void
?Form1_Load(
object
?sender,?System.EventArgs?e)

????????
{
????????
????????}
?}
摘要: pull模式
????????
protected
?
void
?Page_Load(
object
?sender,?System.EventArgs?e)????????
{????????????
//
?在...
閱讀全文
摘要: 使用DataRelation類創建關系并利用父/子關系讀取數據示例void?Page_Load(object?sender,?System.EventArgs?e)????????????{????????????????//?連接字符串和?SQL?語句????????????????string?ConnString?=?System.Configuration.ConfigurationSet...
閱讀全文
摘要: 思路:建個模版文件,再用C#讀此文件,把里面的標記替換掉。。
閱讀全文