활성 디렉토리를 폴링하는 콘솔 응용 프로그램을 생성하라는 메시지가 표시되었습니다. (C. \ Temp \ Input)VB.net Dir의 파일 이름 읽기 SQL 쿼리 실행
파일이 (filename).SUCCESS
과 함께 들어 오면 SQL 쿼리를 실행하기 위해 파일 이름이 검색됩니다. 따라서
IF fileextension = SUCCESS
SQL 테이블에서 파일 이름을 사용하여 SQL 쿼리를 실행하여 SQL 쿼리를 실행합니다. 원래 파일을 c:\temp\Input\Processed
으로 옮깁니다. 도움이나 조언을 주시면 감사하겠습니다.
업데이트 :
안녕하세요, 여러 사이트 IV에서 몇 가지 모양으로 아래 마련. 지금은 SQL을 잊어 버리고, 메신저 후에 만 파일 이름과 파일이 이미 사용하고 있음을 파일하지만, IO 예외를 받고 메신저의 이동 :
수입 System.IO 수입 선택 System.String 모듈 Module1의
Dim fileName As String = "C:\temp\Input\NR12345.success"
Dim pathname As String = "C:\temp\Input\"
Dim result As String
Dim sourceDir As String = "C:\temp\Input\"
Dim processedDir As String = "C:\temp\Input\Processed\"
Dim fList As String() = Directory.GetFiles(sourceDir, "*.success")
Sub Main()
result = Path.GetFileName(fileName)
Console.WriteLine("GetFileName('{0}') returns '{1}'", fileName, result)
result = Path.GetFileName(pathname)
Console.WriteLine("GetFileName('{0}') returns '{1}'", pathname, result)
Call MySub()
End Sub
Sub MySub()
'Move Files
For Each f As String In fList
'Remove path from the file name.
Dim fName As String = f.Substring(sourceDir.Length = 0)
Dim sourceFile = Path.Combine(sourceDir, fName)
Dim processedFileDir = Path.Combine(processedDir, fName)
' Use the Path.Combine method to safely append the file name to the path.
' Will overwrite if the destination file already exists.
File.Copy(Path.Combine(sourceDir, fName), Path.Combine(processedDir, fName), True)
'File.Copy(sourceFile, processedFileDir)
Next f
End Sub
내가 전에 사용했습니다
많은 분들께 감사드립니다. – Gerry85
우수. 데이터 조작에 대한 당신의 접근 방식은 당신이 당신의 RDBMS (mysql, sql-server etc)를 어떻게하고 싶은지에 달려 있으며, 파일 이동의 처리는 매우 간단하고 머리 위로 떨어져있다. System.IO.File.Move (sourceFilePath, destinationFilePath) – Ric
환호성 Ric, SQL Server에 연결하여 jobId의 상태를 변경하려고합니다. ID는 확장명 앞에있는 파일 이름입니다. – Gerry85