For Each i In My.Computer.FileSystem.Drives
10年积累的成都网站制作、做网站经验,可以快速应对客户对网站的新想法和需求。提供各种问题对应的解决方案。让选择我们的客户得到更好、更有力的网络服务。我虽然不认识你,你也不认识我。但先建设网站后付款的网站建设流程,更有虎丘免费网站建设让你可以放心的选择与我们合作。
Dim FSW As New FileSystemWatcher
FSW.NotifyFilter = NotifyFilters.FileName
FSW.Path = i.Name.ToString
FSW.Filter = "*.txt"
AddHandler FSW.Changed, AddressOf FileSystemWatcher1_Changed '与FileSystemWatcher1_Changed事件绑定,以下同。
AddHandler FSW.Created, AddressOf FileSystemWatcher1_Created
AddHandler FSW.Deleted, AddressOf FileSystemWatcher1_Deleted
AddHandler FSW.Disposed, AddressOf FileSystemWatcher1_Disposed
AddHandler FSW.Error, AddressOf FileSystemWatcher1_Error
AddHandler FSW.Renamed, AddressOf FileSystemWatcher1_Renamed
FSW.EnableRaisingEvents = True
Next
上面代码放到一个调用过程中
Private Sub FileSystemWatcher1_Created(sender As Object, e As FileSystemEventArgs) Handles FileSystemWatcher1.Created
‘我用fsw的path属性区别多个分区,你用自己的代码就行,如果你没有创建FileSystemWatcher1,就把Handles FileSystemWatcher1.Created删除。
If sender.path = "C:\" Then
'代码
ElseIf sender.path = "D:\" Then
'代码
ElseIf sender.path = "F:\" Then
ElseIf sender.path = "H:\" Then
'……
End If
End Sub
把变量定义时增加Shared关键字即可.如:
Private
Shared
AAA
As
String
Public
Shared
AAA
As
String
......
这样AAA在一个应用程序里就是公用的.
------------------------------------------------------
补充:
不可能没用,我都是这样做的.
该控件使用中,自己看吧:
Public
Class
CMB_MemoryTextBox
Inherits
TextBox
#Region
"
变量定义
"
Private
Shared
p_HisData
As
STRU_DATA
'用数据表保存所有控件的历史记录
Private
Shared
p_FileName
As
String
'保存历史记录的文件名
......
我想了两种思路,winform没有findControl,只有个this.Controls.Contains("textBox1"),因此除了遍历没办法了。。。
思路1:遍历Controls,具体你自己完善下,
if(this.Controls.Count0)
{
foreach(Control c in this.Controls)
if(c.GetTepy==Tepyof(TextBox))
string str += ((TextBox)c).Text;
}