【发布时间】:2015-06-26 18:29:58
【问题描述】:
所以我使用 wget 从输入文件中下载几百个文件,我使用 Integer 函数让它在每次运行时递增文件编号,但文件编号如下:
1.ext
2.ext
3.ext
但是我希望它们的编号如下:
001.ext
002.ext
003.ext
文件的最大数量当然会达到 999,目前我正在使用下面的代码,但我不知道如何让 VB 使用 3 位数的值而不是 1。
我用来增加数字的代码是:
Dim i As Integer
i += 1
但它不允许我使用 3 数值,有什么帮助吗?
当前代码:
Dim readfilelinks() As String = IO.File.ReadAllLines("tmp\file_links.mda")
For Each line As String In readfilelinks
Command1 = CommandForm.File_Command12.Text
Command2 = CommandForm.File_Command12_1.Text
Dim Com11 As New ProcessStartInfo
Com11.FileName = "cmd.exe"
Com11.Arguments = Command1 & Resources & "\tmp\file_links\" & (i) & ".txt" & Command2 & " " & Command2 & line & Command2
Com11.UseShellExecute = True
Com11.WindowStyle = ProcessWindowStyle.Normal
Dim proc11 As Process = Process.Start(Com11)
proc11.WaitForExit()
Next
上面执行:
wget.exe --no-check-certificate -O "C:\Somedir\tmp\1.txt" "hxxp://somewebsite.com"
wget.exe --no-check-certificate -O "C:\Somedir\tmp\2.txt" "hxxp://somewebsite.com"
wget.exe --no-check-certificate -O "C:\Somedir\tmp\3.txt" "hxxp://somewebsite.com"
工作代码:
Dim readfilelinks() As String = IO.File.ReadAllLines("tmp\file_links.mda")
Dim i As Int32 = 0
For Each link As String In readfilelinks
Command1 = CommandForm.SoundCloud_Command12.Text
Command2 = CommandForm.SoundCloud_Command12_1.Text
Dim Com11 As New ProcessStartInfo
Com11.FileName = "cmd.exe"
Com11.Arguments = Command1 & Resources & "\tmp\file_links\" & (String.Format("{0:000}", i)) & ".txt" & Command2 & " " & Command2 & link & Command2
Com11.UseShellExecute = True
Com11.WindowStyle = ProcessWindowStyle.Normal
Dim proc11 As Process = Process.Start(Com11)
proc11.WaitForExit()
i += 1
Next
执行 wget 命令并将文件输出为 001.txt、002.txt、003.txt 等。
感谢法比奥。
谢谢
基山
【问题讨论】:
-
对不起,我的拼写错误,这是我目前使用的。