使用VS 2015和ASP.net/VB。显示网络目录中的图像
在我的桌面上,我正在构建一个保存在远程服务器(开发服务器)上的Web应用程序。如果我使用VS运行网站,那么一切正常。
我想演示Web应用程序给用户,我遇到了页面上的图像问题。我确定有一些东西很容易丢失,但我无法找到解决方案。当我演示它时,我使用一个URL到服务器(http://DevelopmentServer/myName/website1/default.aspx),当我在我的PC上运行它的本地主机等。
在页面中我有一个上传文件控件,用户可以使用上传图像。完成后,图像显示在屏幕上。我遇到的问题是文件路径。要上传图片,我使用下面的代码。
Protected Sub upLoadFile(sender As Object, e As EventArgs)
Dim fileExt As String = Path.GetExtension(chartUpload.PostedFile.FileName)
Dim folderPath As String = "\\developmentServer\website1\charts\"
Dim fileName As String = "Chart_" & Date.Now.ToString("ddMMyyyy")
Dim updatedFilename As String = fileName & fileExt
chartUpload.SaveAs(Path.Combine(folderPath & updatedFilename))
displayCurrentChart()
End Sub
以上工作正常使用url时 - http://DevelopmentServer/myName/website1/default.aspx
时,我想用下面的代码来显示图像时出现的问题:
Private Sub displayCurrentChart()
Dim chartName As String = "Chart_" & Date.Now.ToString("ddMMyyyy") & ".jpg"
Dim folderPath As String = "D:\Developement\Website1\charts\"
Dim fullFilePath As String = folderPath & chartName
chartImage.Visible = False
If My.Computer.FileSystem.FileExists(fullFilePath) Then
chartImage.ImageUrl = fullFilePath
chartImage.Visible = True
Else
'do nothing
End If
End Sub
我只看到一个黑色的十字架。我相信它与我正在使用的路径有关,因为显然用户没有D驱动器,但如果我使用UNC路径
\\developmentServer\website1\charts\
也不起作用。
有什么建议吗?