0
텍스트 내용이있는 파일을 읽습니다.텍스트 파일 열기/읽기시 오류/교착 상태 감지/방지
샘플하는 dictionary.txt 내용 :
aa abaca abroad apple
발췌문 A :
Dim path as String = Server.MapPath("dictionary.txt");
Dim dictionary() as String = {}
Try
{
dictionary = File.ReadAllLines(path)
}
Catch ex as Exception
End Try
발췌문 B :
스 니펫에서Dim path as String = Server.MapPath("dictionary.txt");
Dim dictionary As New List(Of String)
Using fs As FileStream = New FileStream(path, FileMode.Open, FileAccess.Read, FileShare.ReadWrite)
Using sr As StreamReader = New StreamReader(fs)
While Not sr.EndOfStream
dictionary.Add(sr.ReadLine().Trim())
End While
End Using
End Using
, 나는 거의 한는 오류가 발생하지 않습니다 "파일이 다른 프로세스에서 사용 "합니다. 스 니펫 B에서 아직 동일한 오류가 발생하지 않았습니다.
기본적으로이 오류를 처리/예방할 수 있는지 확인하고 싶습니다. 스 니펫 B가 문제를 해결하지 못하면 다른 방법으로이 오류를 예방할 수 있습니다.
현재이 웹 응용 프로그램이며 여러 사용자가 필요합니다.