成人免费xxxxx在线视频软件_久久精品久久久_亚洲国产精品久久久_天天色天天色_亚洲人成一区_欧美一级欧美三级在线观看

VB.NET批量重命名修改大揭秘

開發 后端
文章主要介紹了VB.NET重命名的批量問題的解決,用一個實例來講解,代碼如:Public Class Form1 Inherits System.Windows.Forms.Form...

學習VB.NET編程的都知道重命名的問題,隨著我在工作中的積累,對VB.NET批量重命名的代碼編輯上做了一些總結,下面給大家列舉一個VB.NET批量重命名代碼實例,希望可以給大家帶來幫助。

  1. Imports System.IO  
  2. Public Class Form1  
  3. Inherits System.Windows.Forms.Form  
  4. #Region " Windows 窗體設計器生成的代碼 "  
  5. Public Sub New()  
  6. MyBase.New()  
  7. '該調用是 Windows 窗體設計器所必需的。  
  8. InitializeComponent()  
  9. '在 InitializeComponent() 調用之后添加任何初始化  
  10. End Sub  
  11. '窗體重寫 dispose 以清理組件列表。  
  12. Protected Overloads Overrides Sub Dispose(ByVal disposing As Boolean)  
  13. If disposing Then  
  14. If Not (components Is Nothing) Then  
  15. components.Dispose()  
  16. End If  
  17. End If  
  18. MyBase.Dispose(disposing)  
  19. End Sub  
  20. 'Windows 窗體設計器所必需的  
  21. Private components As System.ComponentModel.IContainer  
  22. '注意: 以下過程是 Windows 窗體設計器所必需的  
  23. '可以使用 Windows 窗體設計器修改此過程。  
  24. '不要使用代碼編輯器修改它。  
  25. Friend WithEvents Button1 As System.Windows.Forms.Button  
  26. Friend WithEvents TextBox1 As System.Windows.Forms.TextBox  
  27. Friend WithEvents Button2 As System.Windows.Forms.Button  
  28. Friend WithEvents ComboBox1 As System.Windows.Forms.ComboBox  
  29. Friend WithEvents TextBox2 As System.Windows.Forms.TextBox  
  30. Friend WithEvents Button3 As System.Windows.Forms.Button  
  31. Friend WithEvents Label1 As System.Windows.Forms.Label  
  32. Friend WithEvents ProgressBar1 As System.Windows.Forms.ProgressBar  
  33. Friend WithEvents Label2 As System.Windows.Forms.Label  
  34. Friend WithEvents CheckBox1 As System.Windows.Forms.CheckBox  
  35. Friend WithEvents MainMenu1 As System.Windows.Forms.MainMenu  
  36. Friend WithEvents LinkLabel1 As System.Windows.Forms.LinkLabel  
  37. <System.Diagnostics.DebuggerStepThrough()> Private Sub InitializeComponent()  
  38. Me.Button1 = New System.Windows.Forms.Button  
  39. Me.TextBox1 = New System.Windows.Forms.TextBox  
  40. Me.Button2 = New System.Windows.Forms.Button  
  41. Me.ComboBox1 = New System.Windows.Forms.ComboBox  
  42. Me.TextBox2 = New System.Windows.Forms.TextBox  
  43. Me.Button3 = New System.Windows.Forms.Button  
  44. Me.Label1 = New System.Windows.Forms.Label  
  45. Me.ProgressBar1 = New System.Windows.Forms.ProgressBar  
  46. Me.Label2 = New System.Windows.Forms.Label  
  47. Me.CheckBox1 = New System.Windows.Forms.CheckBox  
  48. Me.MainMenu1 = New System.Windows.Forms.MainMenu  
  49. Me.LinkLabel1 = New System.Windows.Forms.LinkLabel  
  50. Me.SuspendLayout()  
  51. '  
  52. 'Button1  
  53. '  
  54. Me.Button1.Location = New System.Drawing.Point(288, 120)  
  55. Me.Button1.Name = "Button1" 
  56. Me.Button1.Size = New System.Drawing.Size(112, 32)  
  57. Me.Button1.TabIndex = 0 
  58. Me.Button1.Text = "執行" 
  59. '  
  60. 'TextBox1  
  61. '  
  62. Me.TextBox1.Location = New System.Drawing.Point(32, 40)  
  63. Me.TextBox1.Name = "TextBox1" 
  64. Me.TextBox1.Size = New System.Drawing.Size(272, 21)  
  65. Me.TextBox1.TabIndex = 1  
  66. Me.TextBox1.Text = "TextBox1" 
  67. '  
  68. 'Button2  
  69. '  
  70. Me.Button2.Location = New System.Drawing.Point(336, 40)  
  71. Me.Button2.Name = "Button2" 
  72. Me.Button2.Size = New System.Drawing.Size(104, 23)  
  73. Me.Button2.TabIndex = 2  
  74. Me.Button2.Text = "目標文件夾..." 
  75. '  
  76. 'ComboBox1  
  77. '  
  78. Me.ComboBox1.Location = New System.Drawing.Point(168, 88)  
  79. Me.ComboBox1.Name = "ComboBox1" 
  80. Me.ComboBox1.Size = New System.Drawing.Size(80, 20)  
  81. Me.ComboBox1.TabIndex = 3 
  82. Me.ComboBox1.Text = "ComboBox1" 
  83. '  
  84. 'TextBox2  
  85. '  
  86. Me.TextBox2.Location = New System.Drawing.Point(168, 128)  
  87. Me.TextBox2.Name = "TextBox2" 
  88. Me.TextBox2.Size = New System.Drawing.Size(80, 21)  
  89. Me.TextBox2.TabIndex = 4 
  90. Me.TextBox2.Text = "" 
  91. '  
  92. 'Button3  
  93. '  
  94. Me.Button3.Location = New System.Drawing.Point(40, 128)  
  95. Me.Button3.Name = "Button3" 
  96. Me.Button3.Size = New System.Drawing.Size(80, 23)  
  97. Me.Button3.TabIndex = 5 
  98. Me.Button3.Text = "新增文件類型" 
  99. '  
  100. 'Label1  
  101. '  
  102. Me.Label1.Location = New System.Drawing.Point(40, 88)  
  103. Me.Label1.Name = "Label1" 
  104. Me.Label1.Size = New System.Drawing.Size(104, 23)  
  105. Me.Label1.TabIndex = 6 
  106. Me.Label1.Text = "要操作的文件類型" 
  107. '  
  108. 'ProgressBar1  
  109. '  
  110. Me.ProgressBar1.Location = New System.Drawing.Point(40, 168)  
  111. Me.ProgressBar1.Name = "ProgressBar1" 
  112. Me.ProgressBar1.Size = New System.Drawing.Size(352, 16)  
  113. Me.ProgressBar1.TabIndex = 7 
  114. '  
  115. 'Label2  
  116. '  
  117. Me.Label2.Location = New System.Drawing.Point(32, 192)  
  118. Me.Label2.Name = "Label2" 
  119. Me.Label2.Size = New System.Drawing.Size(240, 24)  
  120. Me.Label2.TabIndex = 8 
  121. Me.Label2.Text = "狀態" 
  122. '  
  123. 'CheckBox1  
  124. '  
  125. Me.CheckBox1.Location = New System.Drawing.Point(304, 80)  
  126. Me.CheckBox1.Name = "CheckBox1" 
  127. Me.CheckBox1.Size = New System.Drawing.Size(136, 24)  
  128. Me.CheckBox1.TabIndex = 9 
  129. Me.CheckBox1.Text = "完成后打開文件夾" 
  130. '  
  131. 'LinkLabel1  
  132. '  
  133. Me.LinkLabel1.Location = New System.Drawing.Point(296, 200)  
  134. Me.LinkLabel1.Name = "LinkLabel1" 
  135. Me.LinkLabel1.Size = New System.Drawing.Size(144, 23)  
  136. Me.LinkLabel1.TabIndex = 10 
  137. Me.LinkLabel1.TabStop = True 
  138. Me.LinkLabel1.Text = "http://www.wgscd.com" 
  139. '  
  140. 'Form1  
  141. '  
  142. Me.AutoScaleBaseSize = New System.Drawing.Size(6, 14)  
  143. Me.ClientSize = New System.Drawing.Size(464, 238)  
  144. Me.Controls.Add(Me.LinkLabel1)  
  145. Me.Controls.Add(Me.CheckBox1)  
  146. Me.Controls.Add(Me.Label2)  
  147. Me.Controls.Add(Me.ProgressBar1)  
  148. Me.Controls.Add(Me.Label1)  
  149. Me.Controls.Add(Me.Button3)  
  150. Me.Controls.Add(Me.TextBox2)  
  151. Me.Controls.Add(Me.ComboBox1)  
  152. Me.Controls.Add(Me.Button2)  
  153. Me.Controls.Add(Me.TextBox1)  
  154. Me.Controls.Add(Me.Button1)  
  155. MeMe.Menu = Me.MainMenu1  
  156. Me.Name = "Form1" 
  157. Me.Text = "批量重命名 wgscd 2005" 
  158. Me.ResumeLayout(False)  
  159. End Sub  
  160. #End Region  
  161. Dim Path As String = "" 
  162. Dim Filter As String = "*.*" 
  163. Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click  
  164. Filter = Me.ComboBox1.SelectedItem  
  165. Dim dir As DirectoryInfo  
  166. Path = Me.TextBox1.Text  
  167. If Path <> "" AndAlso Me.ComboBox1.Text <> "" Then  
  168. ' If Me.TextBox1.Text.Trim.Length > 6 Then  
  169. '  MsgBox("文件類型錯誤")  
  170. '  Exit Sub  
  171. '  End If  
  172. Dim D As New DirectoryInfo("Temp")  
  173. If D.Exists = False Then  
  174. D.Create()  
  175. End If  
  176. dir = New DirectoryInfo(Me.TextBox1.Text)  
  177. Dim lenth As Integer = dir.GetFiles(Filter).Length  
  178. If lenth > 0 Then  
  179. Me.ProgressBar1.Value = 0 
  180. Me.ProgressBar1.Maximum = lenth + 1  
  181. Me.Label2.Text = "正在復制到臨時目錄。。。" 
  182. Dim fi As FileInfo  
  183. Dim i As Integer = 1 
  184. For Each fi In dir.GetFiles(Filter)  
  185. Dim Temp As String = fi.Name  
  186. Dim Extention As String = fi.Extension  
  187. fi.CopyTo("Temp\" & i & Extention, True)  
  188. fi.Delete()  
  189. i += 1  
  190. Me.ProgressBar1.Value = i 
  191. Next  
  192. Me.ProgressBar1.Value = 0 
  193. Me.Label2.Text = "復制到臨時目錄完成" 
  194. Me.Label2.Text = "正在刪除臨時文件。。。" 
  195. dir = New DirectoryInfo("Temp")  
  196. If dir.GetFiles(Filter).Length Then  
  197. Dim fi2 As FileInfo  
  198. Dim j As Integer = 1 
  199. For Each fi2 In dir.GetFiles(Filter)  
  200. Dim Temp As String = fi2.Name  
  201. Dim Extention As String = fi2.Extension  
  202. fi2.CopyTo(Path & "\" & j & Extention, True)  
  203. fi2.Delete()  
  204. j += 1  
  205. Me.ProgressBar1.Value = j 
  206. Next  
  207. Me.Label2.Text = "處理完成" 
  208. If Me.CheckBox1.Checked Then  
  209. Dim p As New Process  
  210. p.Start(Path)  
  211. End If  
  212. End If  
  213. Else : Exit Sub  
  214. End If  
  215. Else  
  216. MsgBox("請選擇設置操作路徑和要文件類型")  
  217. End If  
  218. End Sub  
  219. Private Sub Form1_Load(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles MyBase.Load  
  220. Me.TextBox1.Text = System.Environment.GetFolderPath(Environment.SpecialFolder.MyPictures)  
  221. Me.ComboBox1.Items.AddRange(New String() {"*.*", "*.jpg", ".gif", "*.bmp", "*.tif", "*.png", "*.html", "*.htm", "*.asp", "*.aspx"})  
  222. ComboBox1.SelectedIndex = 1  
  223. TextBox2.Text = "例如*.jsp" 
  224. End Sub  
  225. Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click  
  226. If TextBox2.Text <> "" Then  
  227. If Me.TextBox2.Text.Trim Like "*.*" Then  
  228. Me.ComboBox1.Items.Add(TextBox2.Text.Trim)  
  229. MeMe.ComboBox1.SelectedIndex = Me.ComboBox1.Items.Count - 1  
  230. End If  
  231. End If  
  232. End Sub  
  233. Private Sub Button2_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button2.Click  
  234. Dim ofd As New FolderBrowserDialog  
  235. If ofd.ShowDialog = DialogResult.OK Then  
  236. Me.TextBox1.Text = ofd.SelectedPath  
  237. End If  
  238. End Sub  
  239. Private Sub LinkLabel1_LinkClicked(ByVal sender As System.Object, ByVal e As System.Windows.Forms.LinkLabelLinkClickedEventArgs) Handles LinkLabel1.LinkClicked  
  240. Dim p As New Process  
  241. p.Start(Me.LinkLabel1.Text)  
  242. End Sub  
  243. End Class 

以上就是VB.NET批量重命名處理,大家試試吧!

【編輯推薦】

  1. 程序員必看VB.NET CASE語句拓展篇
  2. 深入介紹VB.NET類庫 SmartRWLocker技巧
  3. VB.NET復制讀取音頻文件到剪貼板小技巧
  4. 深入概括VB.NET運行環境
  5. 快速使用VB.NET搜索程序實例
責任編輯:田樹 來源: 博客
相關推薦

2010-01-07 15:18:10

VB.NET常量

2009-10-28 12:28:52

VB.NET資源使用

2009-11-10 15:36:24

VB.NET命名約定

2010-01-15 10:47:15

VB.NET命名空間

2009-10-27 14:49:11

VB.NET命名規范

2010-01-18 16:26:46

VB.NET數組賦值

2010-01-08 16:19:00

VB.NET類型單位命

2009-10-27 14:32:45

VB.NET類型級命名

2010-01-20 18:51:16

VB.NET修改系統時

2009-10-23 14:54:07

VB.NET命名空間

2009-10-29 14:02:24

VB和VB.NET比較

2009-11-10 11:01:05

VB.NET事件

2009-10-20 14:21:55

VB.NET fnSi

2009-10-14 12:51:41

VB.NET Data

2011-06-17 11:05:22

VB.NET

2009-06-24 15:45:32

VB.NET

2009-10-23 16:53:16

VB.NET語法規則

2009-11-02 17:12:01

VB和VB.NET

2009-10-27 15:07:40

VB.NET支付寶接口

2010-01-21 17:34:48

VB.NET Bool
點贊
收藏

51CTO技術棧公眾號

主站蜘蛛池模板: 国产精品久久久久一区二区三区 | 久久久久国产成人精品亚洲午夜 | 国产在线视频网 | 久久久久亚洲精品 | 精品国产一区二区国模嫣然 | 亚洲国产午夜 | 在线国产欧美 | 欧美一区二区三区在线播放 | 欧美视频成人 | 黄色毛片大全 | 欧美精品乱码久久久久久按摩 | 亚洲黄色在线免费观看 | 欧美日韩精品影院 | 男女网站免费 | 超碰97免费观看 | 四虎影院免费在线播放 | 色橹橹欧美在线观看视频高清 | 中文字幕在线观看www | 伊人网站在线观看 | 中文字幕一区二区三区在线观看 | 国产精品伦一区二区三级视频 | 亚洲欧美中文日韩在线 | 欧美精品福利 | 日本久久福利 | 欧美一区二区三区在线播放 | 美女久久 | 国产福利在线视频 | 成人在线亚洲 | 美女视频网站久久 | 午夜视频免费在线 | 国产三级精品三级在线观看四季网 | 久久综合一区 | 手机在线不卡av | 久久99网 | 国产二区三区 | 久久久网 | 一区二区三区四区在线视频 | 国产在线h| 国产免费一区 | 亚洲久草视频 | 欧美色专区 |