在vb.net中搜索文件夹并重命名文件
大家好
我是vb编程的新手,但需要一些帮助.
我正在通过将dbase文件导入到MS Access来处理数据库.dbase文件的名称为"BASELINE_points_JUNO2.dbf",众所周知,我必须将其重命名为较小的名称才能在Access中打开它.因此,我手动重命名了20数据到达时每天都有dbf文件.
我将dBase文件保存在计算机上的以下目录中.F:\LatestDownload\2011_10_01_JunoDownload
如您所见,"2011_10_01"部分用于定义数据收集的日期.在该文件夹中,我每天存储约20个dBase文件,并将它们重命名为"JUNO2.dbf","JUNO1.dbf"等,并每天在目录中名称会根据数据收集的日期更改,例如"F:\LatestDownload\2011_10_02_JunoDownload"
然后是"F:\LatestDownload\2011_10_03_JunoDownload"
.
我可以编写一个程序来重命名文件,但是我不知道如何制作一个可以根据日期更改文件夹名称的程序.我的currnet代码是这个,但这不是我想要的.
hi everyone
I am very new to vb programming but I need some help.
I am handling a database by importing dbase files to MS Access.The dbase files are named as "BASELINE_points_JUNO2.dbf" and as you all know I have to rename it to a smaller name to get it opened in access.So I manually rename 20 dbf files everyday when the data arrive.
I save the dBase files on my computer in the following directory.F:\LatestDownload\2011_10_01_JunoDownload
As you can see the "2011_10_01" part is to define day the data was collected.And inside that folder I store about 20 dBase files everyday and rename them as "JUNO2.dbf","JUNO1.dbf" etc and each day the directory name gets changes like "F:\LatestDownload\2011_10_02_JunoDownload"
and then "F:\LatestDownload\2011_10_03_JunoDownload"
according to the date the data was collected.
I can write a program to rename the files but I dont know how to make a program that would work with the folder name changing according to the date.My currnet code is this but it is not what I want.
Private Sub Button3_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button3.Click
Dim j2 As String = "F:\LatestDownload\2011_10_01_JunoDownload\JUNO_2_SURVEY\BASELINE_points_JUNO2.dbf"
Dim j1 As String = "F:\LatestDownload\2011_10_01_JunoDownload\JUNO_1_SURVEY\BASELINE_points_JUNO1.dbf"
Try
If File.Exists(j2) Then
My.Computer.FileSystem.RenameFile(j1, "juno1.dbf")
End If
If File.Exists(j2) Then
My.Computer.FileSystem.RenameFile(j2, "juno2.dbf")
End If
Catch ex As Exception
End Try
End Sub
您能帮我吗,我无法更改默认的dbase文件名,因为我们使用的掌上电脑无法自定义.
谢谢
Can you please help me.I cant change the default dbase file names becuase the palm tops we use are not customizable.
Thank you
尝试:
现在
Try:
Dim now as DateTime = DateTime.Now
Dim j2 as string = string.Format("F:\LatestDownLoad\{0:0000}_{1:00}_{2:00}_JunoDownload\JUNO_2_SURVEY\BASELINE_points_JUNO2.dbf", now.Year, now.Month, now.Day)