JAVA程序中点击按钮打开文件对话框 10
点击按钮打开文件对话框,只显示txt格式的文件,将选择的文件输出到文本域中,怎么实现呀??明天就要交作业了。。。。555555555555~...
点击按钮打开文件对话框,只显示txt格式的文件,将选择的文件输出到文本域中,怎么实现呀??明天就要交作业了。。。。555555555555~
展开
1个回答
展开全部
1.打开文件
Dim clsIntCmn As New WxsIntCmn
Dim strpath As String = txtPath.Text
clsIntCmn.Openfile(strpath, Page)
System.Diagnostics.Process.Start(strpath)
2.上传文件
Public Function Savefile(ByVal strFilepath As String, ByVal Request As HttpFileCollection) As Boolean
Dim bolflag As Boolean = True
Dim uploadedFiles As HttpFileCollection = Request
For i As Integer = 0 To uploadedFiles.Count - 1
Dim userPostedFile As HttpPostedFile = uploadedFiles(i)
Try
'要保存文件的路径
Dim strPath As String = strFilepath & "\" & _
System.IO.Path.GetFileName(userPostedFile.FileName)
If (userPostedFile.ContentLength > 0) Then
'保存文件
userPostedFile.SaveAs(strPath)
End If
txtPath.Text = strPath
txtDelPath.Text = strPath
Catch ex As Exception
bolflag = False
i = uploadedFiles.Count
End Try
Next
Return bolflag
End Function
这是我曾经写过的,也已经用过,试试吧!应该可以帮助你的,不过你要改用一下语言
Dim clsIntCmn As New WxsIntCmn
Dim strpath As String = txtPath.Text
clsIntCmn.Openfile(strpath, Page)
System.Diagnostics.Process.Start(strpath)
2.上传文件
Public Function Savefile(ByVal strFilepath As String, ByVal Request As HttpFileCollection) As Boolean
Dim bolflag As Boolean = True
Dim uploadedFiles As HttpFileCollection = Request
For i As Integer = 0 To uploadedFiles.Count - 1
Dim userPostedFile As HttpPostedFile = uploadedFiles(i)
Try
'要保存文件的路径
Dim strPath As String = strFilepath & "\" & _
System.IO.Path.GetFileName(userPostedFile.FileName)
If (userPostedFile.ContentLength > 0) Then
'保存文件
userPostedFile.SaveAs(strPath)
End If
txtPath.Text = strPath
txtDelPath.Text = strPath
Catch ex As Exception
bolflag = False
i = uploadedFiles.Count
End Try
Next
Return bolflag
End Function
这是我曾经写过的,也已经用过,试试吧!应该可以帮助你的,不过你要改用一下语言
已赞过
已踩过<
评论
收起
你对这个回答的评价是?
推荐律师服务:
若未解决您的问题,请您详细描述您的问题,通过百度律临进行免费专业咨询