1 year ago

#387595

test-img

RowanWinged

Four character extension files will not download in deployment

I have a web application written in visual basic. I am trying to download files from the database; which works fine for any file with 3 characters in its extension. Any four character responds with a 'page not found' in the deployed version. In the development version the both file types download correctly. Looking for any information to help.

Here is a bit of the code (note: this executes on a button click event):

    Dim myDataReader As SqlClient.SqlDataReader
    myDataReader = Me.SqlCommandFileGrab.ExecuteReader

    myDataReader.Read()

    'check for null file content
    If myDataReader.GetValue(1) Is System.DBNull.Value Then
        Response.Write(ClientScripts.ShowAlert("No attachment found."))
        myDataReader.Close()
        Exit Sub
    End If

    'check download directory

    Dim myDir As System.IO.DirectoryInfo

    myDir = New System.IO.DirectoryInfo(Server.MapPath("Temp\") + Session("loginUser"))

    If Not myDir.Exists Then
        myDir.Create()
    End If

        'get file location

        Dim FilePath As String
        Dim FileExt As String
        Dim File As String

        File = myDataReader.GetValue(0).ToString
        FileExt = File.Substring(File.LastIndexOf(".") + 1)
        FilePath = Server.MapPath("Temp\") + Session("loginUser") + "\SaveFile." + FileExt

    'download file

    Dim myFile As New System.IO.FileStream(FilePath, IO.FileMode.Create)
    Dim stWriter As New System.IO.BinaryWriter(myFile)

    stWriter.Write(myDataReader.GetValue(1))

    myFile.Close()
    stWriter.Close()
    myDataReader.Close()

    'display file
    Dim httpPath As String
    httpPath = "Temp/" + Session("loginUser") + "/SaveFile." + FileExt
    Response.Write(ClientScripts.OpenLink(httpPath))

database

vb.net

visual-studio

file

web-applications

0 Answers

Your Answer

Accepted video resources