目前我将尝试从SQL数据库从一个Web应用程序VB.NET
这里检索文件路径打开我的web应用程序文件打开一个文件,是我的代码,将打开的时候我双倍的文件单击列表框中的一个索引。
Protected Sub userdoubleClick()
Dim selectedPath As String
Try
fileConnection.Open()
selectedFile = FileListBox.SelectedValue
'takes the selected items from the listbox and searches the database for the file
'and will open the file for the user
fileCommand.CommandText = "SELECT filePath FROM ImportedFiles WHERE FileName = '" & selectedFile & "'"
fileDataReader = fileCommand.ExecuteReader
Do While fileDataReader.Read
selectedPath = fileDataReader.GetValue(0)
Loop
System.Diagnostics.Process.Start(selectedPath)
Catch ex As Exception
End Try
fileConnection.Close()
End Sub
当我在本地PC上运行它时,它工作正常,但是当我将它发布到服务器时,它不会打开文件。
你在说什么?本地机器上的路径?相对于您网站根目录的路径?请提供示例 – Steve
文件路径位于共享驱动器中,并且看起来像这样\\ webapp \ backup \ Archived \ 20150709_1324849.pdf – averyto8
打开文件后,您要如何处理该文件?你是否将内容返回给浏览器?你正在处理文件?另外,当你说它“不会打开”你是什么意思?你是否遇到异常?我敢打赌,例外是权限问题,特别是如果文件在共享服务器上。 –