아래 코드는 서로 다른 파일 이름을 기반으로 여러 폴더를 만들고 해당 파일을 새 폴더로 이동합니다. 예를 들어, 파일 ABC 및 XYZ는 ABC 및 XYZ라는 새로 생성 된 폴더로 이동됩니다. 약간 다른 파일 이름이 공용 폴더로 들어가도록 코드를 향상시키고 싶습니다. 예를 들어 ABC_rock, ABC_soil 및 ABC_water 파일을 ABC라는 폴더에 넣고 XYZ_rock, XYZ_soil 및 XYZ_water 파일을 XYZ라는 폴더에 넣기를 원합니다. ABC_rock, ABC_soil 및 ABC_water에 대해 별도의 폴더를 만들지는 않습니다. 어떤 제안이라도 대단히 감사하겠습니다. 도와 줘서 고마워.VB.NET 파일 이름을 기반으로 폴더 만들기
Dim strOutputLocation As String = "C:\Temp"
Dim rootPath As String = strOutputLocation
For Each filepath As String In IO.Directory.GetFiles(rootPath)
Dim folderName As String = IO.Path.GetFileNameWithoutExtension(filepath)
Dim folderPath As String = IO.Path.Combine(rootPath, folderName)
If Not IO.Directory.Exists(folderPath) Then
IO.Directory.CreateDirectory(folderPath)
End If
Dim fileName2 As String = IO.Path.GetFileName(filepath)
Dim newFilePath As String = IO.Path.Combine(folderPath, fileName2)
File.Move(filepath, newFilePath)
Next
감사합니다. – artwork21
__ 대신 두 개의 밑줄로 쪼개려고했으나 첫 번째 _ 인스턴스로 쪼개졌습니다. __로 분할하는 방법은 무엇입니까? – artwork21