OPenFileDialog使用
Private Sub Button1_Click(ByVal sender As System.Object,ByVal e As System.EventArgs) Handles Button1.Click
Dim myStream As System.IO.Stream
openFileDialog1.InitialDirectory = "c:\"
openFileDialog1.Filter = "txt files (*.txt)|*.txt|All files (*.*)|*.*"
openFileDialog1.FilterIndex = 2
OpenFileDialog1.RestoreDirectory = True
If OpenFileDialog1.ShowDialog() = DialogResult.OK Then
MsgBox(OpenFileDialog1.FileName)
myStream = OpenFileDialog1.OpenFile()
If Not (myStream Is Nothing) Then
MessageBox.Show(myStream.Length.ToString)
myStream.Close()
End If
End If
End Sub
filename = OpenFileDialog1.FileName
PictureBox1.Image = System.Drawing.Image.FromFile(filename)
有从服务器上直接把文件导出到本地路径,自然也可以从本地路径中直接读取文件。 好像只要取得远程的本地路径,然后用java类中读取文件的类读这个文件就行了。 FileInputStream ofi = new FileInputStream(文件路径+文件名); InputStreamReader in = new InputStreamReader(ofi,"GBK"); BufferedReader oBufReader = new BufferedReader(in); 然后用readLine()方法逐行读取了。 至于写入数据库,只要把读取的内容按你需要拆分开来,insert到数据库就行了。