위치 문자열에서 텍스트 파일을 읽는 대신 리소스 위치에서 텍스트 파일을 읽도록 변경하고 문제가 발생합니다. 내 프로그램. 또한 삽입 코드 조각 방법을 사용하여이 코드의 대부분을 얻었으므로 어떤 일이 일어나고 있는지 모르겠습니다. 어떤 사람이 도와 주실 수 있습니까?리소스에서 구분 된 텍스트 파일을 읽으려고 시도했습니다. 그러나 실행되지 않습니다.
'reads the text out of a delimited text file and puts the words and hints into to separate arrays
' this works and made the program run
' Dim filename As String = Application.StartupPath + "\ProggramingList.txt"
'this dosnt work and brings back a Illegal characters in path error.
dim filename as string = My.Resources.ProggramingList
Dim fields As String()
'my text files are delimited
Dim delimiter As String = ","
Using parser As New TextFieldParser(filename)
parser.SetDelimiters(delimiter)
While Not parser.EndOfData
' Read in the fields for the current line
fields = parser.ReadFields()
' Add code here to use data in fields variable.
'put the result into two arrays (the fields are the arrays im talking about). one holds the words, and one holds the corresponding hint
Programingwords(counter) = Strings.UCase(fields(0))
counter += 1
'this is where the hint is at
Programingwords(counter) = (fields(1))
counter += 1
End While
End Using
오류
ex.ToString()
"System.ArgumentException :. 경로에 잘못된 문자 System.IO.Path.CheckInvalidPathChars에서 (문자열 경로) System.IO.Path에서 (문자열 경로, 부울 전체 검사) 에서 System.IO.Path.NormalizePath (문자열 경로, 부울 전체 검사) at System.IO.Path.GetFullPathInternal (문자열 경로) at System.IO.Path.GetFullPath (문자열 경로, 부울 전체 검사)) (Microsoft.VisualBasic.FileIO.FileSystem.Nor) Microsoft.VisualBasic.FileIO.TextFieldParser에서 Microsoft.VisualBasic.FileIO.TextFieldParser.InitializeFromPath (문자열 경로, 인코딩 defaultEncoding, 부울 detectEncoding) 에서 Microsoft.VisualBasic.FileIO.TextFieldParser.ValidatePath (문자열 경로) 에서 malizePath (문자열 경로) ..ctor I에서 (문자열 경로) HangMan.Form1.GetWords에서 () : \ VB \ 교수형 집행 \ 교수형 집행 인 \를 Form1.vb :이 코드를 디버깅 할 때 라인 (274)은 "문자열은 값은 무엇인가
'My.Resources.GamesList'가 설정된 곳에 게시 할 수 있습니까? –
내가 리소스 폴더를 추측하고 있습니까? 방금 텍스트 파일을 프로그램 리소스에 추가했습니다. 이 일을하는 유일한 이유는 내 프로그램이 .exe 파일에서 실행될 수 있기 때문입니다. – Bigfatty
죄송합니다. 내 주석 처리되지 않은 코드가 혼동을 일으키고 있다면 사실입니다. 두 파일의 이름은 proggramingList – Bigfatty