0
가능한 중복 : 123.psd 12345.psd 123456.psd 등 :
Read multiple text files in a folder간단한 이름 스크레이퍼
내가 예를 들어, 파일이있는 폴더가 , 나는 폴더 안의 모든 이름을 TXT 파일로 긁어 내고 싶습니다. 어떻게하면됩니까? 감사합니다.
가능한 중복 : 123.psd 12345.psd 123456.psd 등 :
Read multiple text files in a folder간단한 이름 스크레이퍼
내가 예를 들어, 파일이있는 폴더가 , 나는 폴더 안의 모든 이름을 TXT 파일로 긁어 내고 싶습니다. 어떻게하면됩니까? 감사합니다.
당신은 Path.GetFileNameWithoutExtension
사용할 수 있습니다
Dim filesNames = From path In IO.Directory.EnumerateFiles("C:\Temp")
Select IO.Path.GetFileNameWithoutExtension(path)
IO.File.WriteAllLines("C:\Filenames.txt", filesNames)
편집 : 여기에 .NET 3.5에서도 작동하는 버전입니다 :
Dim filesNames = From path In IO.Directory.GetFileSystemEntries("C:\Temp")
Select IO.Path.GetFileNameWithoutExtension(path)
IO.File.WriteAllLines("C:\Filenames.txt", filesNames.ToArray)
는이조차 .NET이 작동합니다
Dim filesNames = IO.Directory.GetFileSystemEntries("C:\Temp")
Dim fileNamesWithoutExtension(filesNames.Length - 1) As String
For i = 0 To filesNames.Length - 1
fileNamesWithoutExtension(i) = IO.Path.GetFileNameWithoutExtension(filesNames(i))
Next
IO.File.WriteAllLines("C:\Filenames.txt", fileNamesWithoutExtension)
@JonEgerton : VB.NET 4에서는'_' (줄 연속)이 필요 없습니다. –
흥미 롭습니다 - VB.Ne의 VS2008에서 작업 해 왔습니다. 그래서 아직도 그들과 붙어 있습니다. 내가 미쳐 가지 않은 내 작업 원격 연결을 확인하고 있었습니까! –
답장을 보내 주셔서 감사합니다. 지금 오류가 거의 없습니다. '사례 선택'은 '끝 선택'과 일치해야합니다. '경로'이름이 선언되지 않았습니다. '사례 선택'과 첫 번째 '사례'간에는 문장과 레이블이 유효하지 않습니다. –