私が取り組んでいるプログラムで働く関数を得るためのガイダンスを探しています。すべてのユーザーのためのvb.netプログラムのクリーンアップ一時ファイルディレクトリのガイダンスを探しています
私が執着している機能は、そのコンピュータ上のすべてのユーザープロファイルのリモートコンピュータ上の複数のディレクトリからすべてのファイルを削除することです。
現時点では、file.delete()を追加する前に、ディレクトリとサブディレクトリにあるすべてのファイルをテキストボックスに出力しようとしています。
ファイルパス内の各文字を別々の項目に分けているので、すべての「項目」が1文字の文字として表示されています(For..Each
と同じように)。
私はVB.netにはまだまだ慣れていないので、学習の段階ではまだ大変ですが、私はいくつかのガイダンスを探しています。
私はそれを検索し、一緒に作品を引っ張ってきましたが、壁に当たった、どんな助けもありがとう!
現在のコード:
Private Sub Deltemp_Click(sender As Object, e As EventArgs) Handles Deltemp.Click
If Compname2.Text = "" Then
MessageBox.Show("You didn't enter anything in the Computername field, please enter something then try again.")
GoTo statementend
End If
Try
If My.Computer.Network.Ping(Compname2.Text, 1000) Then
PSoutput.Text = ""
Else
PSoutput.Text &= Compname2.Text + " is not connected to our network currently."
GoTo statementend
End If
PSoutput.Text = ""
Dim userpath As String = "\\" + Compname2.Text + "\c$\users\"
Dim tempu(7) As String
tempu(0) = "\AppData\Local\Temp\"
tempu(1) = "\AppData\Local\Microsoft\Windows\Temporary Internet Files\"
tempu(2) = "\AppData\Local\Microsoft\Credentials"
tempu(3) = "\AppData\Local\Temporary Internet Files\"
tempu(4) = "\AppData\Roaming\Microsoft\Credentials"
tempu(5) = "\AppData\Roaming\SUN"
tempu(6) = "\AppData\Local\Apps\2.0"
Dim fsd As Object
fsd = FileIO.FileSystem.GetDirectories(userpath)
For Each user In fsd
Try
Dim filepaths = FileIO.SpecialDirectories.AllUsersApplicationData()
If user Like "*Default*" Or user Like "*.NET*" Or user Like "*All Users" Or user Like "*Public" Then
PSoutput.Text &= ""
Else
Dim Fullpath = user + tempu(7)
For Each item In Fullpath
FileIO.FileSystem.GetFiles(Fullpath)
PSoutput.Text &= item.ToString + " was found" & Environment.NewLine
Next
End If
Catch ex As Exception
PSoutput.Text &= "A file was skipped for being in use or an exception occured" & Environment.NewLine
End Try
Next
Catch
MessageBox.Show("The machine/ip entered doesn't exist on our network or is an invalid entry")
End Try
statementend:
End Sub
私はそれが私が行方不明だった何か簡単でなければならないことを知っていた、ありがとうスコット! - 余分な質問があれば、私はこれを実行するとすべてのディレクトリにあるファイルだけを取得することに気付きました。ソースディレクトリにドットを付けると、ディレクトリを取得することもできませんでした。すべてのサブディレクトリが含まれますか?また、 'Option Strict'のヒントをありがとう、私はこれを実装します:) –
いいえ、あなたは再帰的に各ディレクトリ内のディレクトリを取得し、各ディレクトリ内のファイルを取得する必要があります。つまり、ディレクトリを渡すと、そのディレクトリ内のすべてのサブディレクトリが取得され、自身を呼び出します。そうすることで、これ以上サブディレクトリがなくなるまで、すべてのサブディレクトリを通過し続けます。 –
ここに[例](https://support.microsoft.com/en-us/kb/306666)と[もう一つ](http://www.coderslexicon.com/playing-with-recursive-directory-diving)があります。 -in-vb-net /)となる。 –