W
WordVBAProgrammer
I've been struggling with this for a few days now. It worked
originally as plain VB-type strings, but for some reason ceased
creating the FileNm. I changed the code to use StringBuilder, but
only get the file name, not the path.
Can someone point out my error? See notes below code.
....
Dim strFileNm As String
Dim FileNm As New StringBuilder()
If IsInString(ProgInfo.SHDataLists, "bin") Then
FileNm = FileNm.Append("c:\secondhand\datalists\")
FileNm = FileNm.Append("SHDescription.shd")
strFileNm = FileNm.ToString
Else
FileNm = FileNm.Append(ProgInfo.SHDataLists)
FileNm = FileNm.Append("SHDescription.shd")
strFileNm = FileNm.ToString
End If
MessageBox.Show(strFileNm)
Dim objReader As StreamReader = New StreamReader(strFileNm)
....
Public Function IsInString(ByVal String1 As String, ByVal String2 As
String) As Boolean
IsInString = (InStr(String1, String2) > 0)
End Function
===============
Public Class ProgInfo
Public Shared SHDataLists As String
...
End Class
SHDataLists is assigned a path of "C:\Program Files\DHSA\SecondHand\"
MessageBox only for debug purposes.
Imports System.Text has been added
=============
strFileNm = "SHDescription.shd" -- It should equal path and filename.
Crashes at StreamReader with the following
error in CLR Debugger after rebuild and install for testing:
"An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll"
"Additional information: Could not find file "C:\Program
Files\DHSA\SecondHand\SHDescription.shd"."
Thanks IA.
Dan
originally as plain VB-type strings, but for some reason ceased
creating the FileNm. I changed the code to use StringBuilder, but
only get the file name, not the path.
Can someone point out my error? See notes below code.
....
Dim strFileNm As String
Dim FileNm As New StringBuilder()
If IsInString(ProgInfo.SHDataLists, "bin") Then
FileNm = FileNm.Append("c:\secondhand\datalists\")
FileNm = FileNm.Append("SHDescription.shd")
strFileNm = FileNm.ToString
Else
FileNm = FileNm.Append(ProgInfo.SHDataLists)
FileNm = FileNm.Append("SHDescription.shd")
strFileNm = FileNm.ToString
End If
MessageBox.Show(strFileNm)
Dim objReader As StreamReader = New StreamReader(strFileNm)
....
Public Function IsInString(ByVal String1 As String, ByVal String2 As
String) As Boolean
IsInString = (InStr(String1, String2) > 0)
End Function
===============
Public Class ProgInfo
Public Shared SHDataLists As String
...
End Class
SHDataLists is assigned a path of "C:\Program Files\DHSA\SecondHand\"
MessageBox only for debug purposes.
Imports System.Text has been added
=============
strFileNm = "SHDescription.shd" -- It should equal path and filename.
Crashes at StreamReader with the following
error in CLR Debugger after rebuild and install for testing:
"An unhandled exception of type 'System.IO.FileNotFoundException'
occurred in mscorlib.dll"
"Additional information: Could not find file "C:\Program
Files\DHSA\SecondHand\SHDescription.shd"."
Thanks IA.
Dan