网络编程相关

1如果获得当前进程的Id用:

Process[] processes = Process.GetProcesses(); 
foreach(Process process in processes) 
{ 
if(process.ProcessName == "进程名" 
{ 
MessageBox.Show(process.Id); 
} 
}
Process processes =Process.GetCurrentProcess
//processes.id获得当前进程的ID


2如果获得当前线程的ID用:

Thread.CurrentThread.ManagedThreadId.ToString() (推荐)
//或
AppDomain.GetCurrentThreadId().ToString()

3如果获得当前线程的ID用

private void textBox1_KeyDown(object sender, KeyEventArgs e)   
 {     
 if (e.SystemKey == Key.Return || (Keyboard.Modifiers == ModifierKeys.Control && e.Key == Key.Enter))     
 {       
 //添加一个换行字符       
textBox1.SelectedText = Environment.NewLine;        //光标向前移动一位       
textBox1.Select(textBox1.SelectionStart + 1, 0);       
 e.Handled = true;     
}
 }
/WPF实现时间
private void label1_Loaded(object sender, RoutedEventArgs e) 
{ 
   DispatcherTimer timer =new DispatcherTimer(); 
   timer.Interval = new TimeSpan(0, 0, 1);   //间隔1 
   timer.Tick += new EventHandler(timer_Tick); 
   timer.Start(); 
} 
 
void timer_Tick(object sender, EventArgs e) 
{ 
   label1.Content = DateTime.Now.ToString("yyyy年MM月dd日 HH时hh分ss秒");//yyyy年MM月dd日 HH:hh:ss 也可以 
} 

文件夹传输相关

(1)首先要生成DirectoryInfo类的一个实例对象,然后生成一个FileSystemInfo类型的数组,用来记录指定文件夹中的所有目录及子目录,最后循环访问FileSystemInfo中的文件。

textBox1.Text = folderBrowserDialog1.SelectedPath;
DirectoryInfo DInfo = new DirectoryInfo(textBox1.Text);
FileSystemInfo[] FSInfo = DInfo .GetFileSystemInfos();
for(int i=0;i<FSInfo .length;i++)
{
      //将文件显示出来
}


 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值