'Assumes the CSV files first row will be the column names and they will be User Name, Email Address, Date Account Expired, Original OU (currently missing login name)
を提供することができる任意のヘルプ「のtest.CSV」 ログイン名、ユーザー名、電子メールアドレス、日付のアカウントの有効期限が切れ、オリジナルOU Daniel.Gangeを持ってくれてありがとう、Daniel Gange、[email protected]、09/08/2017、 "CN = Daniel Gange、OU =テスト、OU =テスト、DC =テスト、DC = co、DC = uk"
Using sr As StreamReader = File.OpenText("c:\scripts\GmailDisabled.csv")
sr.ReadLine() 'read the first line you said to skip
Do
Dim xData As String = sr.ReadLine() 'read one line at the time
Dim csvValue() As String = xData.Split(",") ' split at every comma (csv file)
' the first value always has index 0 which is username
Dim sUserName As String = csvValue(0)
Dim PathToDelete1 As String = String.Format("\\netapp01fs\profiles\{0}", sUserName)
Dim PathToDelete2 As String = String.Format("\\rukredir\\{0}", sUserName)
MsgBox(PathToDelete1)
MsgBox(PathToDelete2)
Loop Until sr.EndOfStream = True 'loop until the end of file
sr.Close() 'close the csv
End Using
コードが必要な場合は、このフォルダを使用して実際にフォルダを削除します。データを削除するものをテストするときは、絶対にファイルやフォルダを消去しないでください。あなたは、削除したくないものを削除してしまうかもしれません。
'Assumes the CSV files first row will be the column names and they will be User Name, Email Address, Date Account Expired, Original OU (currently missing login name)
Using sr As StreamReader = File.OpenText("c:\scripts\GmailDisabled.csv")
sr.ReadLine() 'read the first line you said to skip
Do
Dim xData As String = sr.ReadLine() 'read one line at the time
Dim csvValue() As String = xData.Split(",") ' split at every comma (csv file)
' the first value always has index 0 which is username
Dim sUserName As String = csvValue(0)
Dim PathToDelete1 As String = String.Format("\\netapp01fs\profiles\{0}", sUserName)
Dim PathToDelete2 As String = String.Format("\\rukredir\\{0}", sUserName)
Directory.Delete(PathToDelete1, True) ' set recursive to True to delete files and sub folders
Directory.Delete(PathToDelete2, True) ' set recursive to True to delete files and sub folders
'MsgBox(PathToDelete1)
'MsgBox(PathToDelete2)
Loop Until sr.EndOfStream = True 'loop until the end of file
sr.Close() 'close the csv
End Using
短いバージョン
'Assumes the CSV files first row will be the column names and they will be User Name, Email Address, Date Account Expired, Original OU (currently missing login name)
Using sr As StreamReader = File.OpenText("c:\scripts\GmailDisabled.csv")
sr.ReadLine() 'read the first line you said to skip
Do
Dim xData As String = sr.ReadLine() 'read one line at the time
' the first value always has index 0 which is username
Directory.Delete(String.Format("\\netapp01fs\profiles\{0}", xData.Split(",")(0)), True) ' set recursive to True to delete files and sub folders
Directory.Delete(String.Format("\\rukredir\\{0}", xData.Split(",")(0)), True) ' set recursive to True to delete files and sub folders
Loop Until sr.EndOfStream = True 'loop until the end of file
sr.Close() 'close the csv
End Using
あなたは私たちにサンプルCSVファイルを表示することができますか?これはvb.netではなくvb6と思われます。 – derloopkat
csvからの行は、この薄暗いcsvValues()のようにstring = sline.split( "、")として簡単に読み取ることができます。私に30分を与えてください。私が戻ってきたら、 – Chillzy
という答えをあなたにもお届けします。ディレクトリ内の私のループを見れば、特定のファイルを見つけることができます: - https://stackoverflow.com/questions/42826832/search-files-basedユーザーが入力したコンソールアプリケーションの日付変更された日付 - v/42832771#42832771 –