我正在尝试在 Windows Azure 上上传文件,但没有成功。我的网站是在VS2013中使用ASP.NET MVC5开发的。它在我的本地计算机上运行良好,但是当我在 Windows Azure 上发布它时,它给了我一个错误:
Could not find a part of the path 'D:\home\site\wwwroot\Uploads\bluedress_21-03-2014.jpg'.
这是我正在使用的代码:
If file.ContentLength > 0 Then
Dim fileName = Path.GetFileName(file.FileName)
Dim fileNameWithoutExt = Path.GetFileNameWithoutExtension(file.FileName)
Dim Ext = Path.GetExtension(file.FileName)
Dim fileNameToSave = fileNameWithoutExt & "_" & Date.Now.ToString("dd-MM-yyyy") & Ext
Dim path__1 = Path.Combine(Server.MapPath("~/Uploads/"), fileNameToSave)
advert.ImageLocation = fileNameToSave file.SaveAs(path__1)
End If
我尝试用谷歌搜索这个问题,但根本没有找到解决方案。有人可以帮我吗?
最佳答案
使用 Azure 网站时,建议的做法是将文件上传到 Azure 存储。如果角色切换为使用另一个虚拟机,上传到虚拟服务器的所有文件都将丢失。如果您出于某种原因确实需要这样做,这里的链接可能会有所帮助:Windows Azure: Working with local storage
关于asp.net - Windows Azure 上的简单文件上传,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/22569358/