-1

listbox1 は、ファイルを含むサブフォルダーを一覧表示します。

listbox2 にはファイルリストがあります。

ボタン1を押すと、リストボックス2内のファイルごとにフォルダーが作成され(フォルダー名はファイル名と同じである必要があります)、対応するファイルをそのディレクトリに移動します。

eg) 
listbox1
d:\data\sub1\
listbox2
d:\data\sub1\a.7z
d:\data\sub1\ab.7z

when button1 is pushed

we can find the files in...

d:\data\sub1\a\a.7z
d:\data\sub1\ab\a.7z

出来なくて困っています。リストボックスにファイルをリストする方法は知っていますが、それぞれのファイルを処理する方法がわかりません。

また、次のコードでディレクトリ名の 7z 拡張子を取り除こうとすると、リストボックスに使用できないと表示されます。

   If folderslist.SelectedItem IsNot Nothing Then
            ' selected item is filepath
            Dim filePath = folderslist.SelectedItem.ToString

         The string you are searching

         Dim s As String = filePath

     Find index of uppercase letter 'B'
          Dim i As String = 0
          Dim j As String = s.IndexOf("."c)


     This new string contains the substring starting at B
       part = s.Substring(i, j - i + 1)

         If (s.IndexOf(".") = -1) Then
    part = "Not found"

       End If

アドバイスをお願いします。

4

2 に答える 2

0
   Private Sub Timer2_Tick(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Timer2.Tick

 If folderslist.SelectedItem IsNot Nothing Then

  Dim filePath = folderslist.SelectedItem.ToString

            fileslist.Items.Clear()


            Dim dirf As String() = Directory.GetFiles(filePath, "*.7z")

            Dim dira As String
            For Each dira In dirf

                fileslist.Items.Add(dira)
            Next


            If mkfold = 1 Then

                For Each dira In dirf

                    Dim pName As String = Path.GetFileNameWithoutExtension(dira)


                    Dim strDir As String
                    strDir = filePath & "\" & pName

                    If DirExists(Trim(strDir)) = False Then
                        MkDir(Trim(strDir))
                    End If


                    Dim f_name As String = Path.GetFileName(dira)
                        My.Computer.FileSystem.MoveFile(dira, strDir & "\" & f_name)
                    Next

               mkfold = 0

            End If

        End If

 Private Sub mkfol_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles mkfol.Click
        mkfold = 1


    End Sub

何とか欲しかったものを手に入れました。

于 2013-06-11T10:39:41.370 に答える