下面的代码在.net2003下能运行,为什么在.net2005的Win CE 下就不行了呢?
请高手看看,在fi = New FileInfo("c:\jan.txt")这里过不了。
Dim fi As FileInfo
fi = New FileInfo("c:\jan.txt")
Dim fs As FileStream = fi.OpenRead()
Dim nBytes As Integer
nBytes = Me.TextBox1.Text
Dim ByteArray(nBytes) As Byte
fs.Read(ByteArray, 0, nBytes)
Me.TextBox2.Text = System.Text.Encoding.Default.GetString(ByteArray, 0, nBytes)
详情回复
发表于 2007-2-12 17:03
Dim sr As System.IO.StreamReader
Dim sw As System.IO.StreamWriter
Dim line As String
Dim AppPath As String = System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().GetName().CodeBase)
psConnectFile = AppPath & "\connect.txt"
psLocalDB = AppPath & "\rdadb.sdf"
Try
If Not System.IO.File.Exists(psConnectFile) Then
sw = New System.IO.StreamWriter(psConnectFile, False)
sw.WriteLine("'external ip address, sql server user, sql server password, sql server database, path to rdaserver")
sw.WriteLine("uyuu")
sw.Flush()
sw.Close()
'Exit Sub
End If
sr = New System.IO.StreamReader(psConnectFile)
' Read and display the lines from the file until the end
' of the file is reached
line = sr.ReadLine()
If line.IndexOf("'") = 0 Then
line = sr.ReadLine()
End If
sr.Close()
Catch ex As Exception
' Let the user know what went wrong.
MessageBox.Show("Error: Cannot read connection file.")
MessageBox.Show(ex.Message)
Exit Sub
Finally
sw = Nothing
sr = Nothing
End Try