Recommended Answers
Jump to PostUse forms authentication to restrict user rights. Then use one function to download file. What exactly do you need?
Jump to PostHere is my function for downloading file:
Public Sub DownloadFile(ByVal path As String) With HttpContext.Current Dim file As IO.FileInfo = New IO.FileInfo(.Server.MapPath(path)) If file.Exists Then .Response.Clear() .Response.AddHeader("Content-Disposition", "attachment; filename=" & file.Name) .Response.AddHeader("Content-Length", file.Length.ToString()) .Response.ContentType = "application/octet-stream" .Response.WriteFile(file.FullName) .Response.End() End If End With End Sub
Put this function …
Jump to PostThe error is very clear. You are passing absolute path instead of relative. Pass string like "~/MyFiles/MyFile.doc". If you want to use absolute path then fix code like this:
Instead of:
Dim file As IO.FileInfo = New IO.FileInfo(.Server.MapPath(path))
Put this:
Dim file As IO.FileInfo = New …
Jump to Postin case anyone ever wants it, there is an excellent example of this on the photo gallery in the Personal Website Starrter Kit
All 14 Replies
We're a friendly, industry-focused community of developers, IT pros, digital marketers, and technology enthusiasts meeting, networking, learning, and sharing knowledge.