473,395 Members | 1,653 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,395 software developers and data experts.

Why is the file being corrupted (using a download tracker)?

I set up a download tracker. When i first tested it, all was fine. However
as i just found out via an email, the zip file is corrupt. Folks can
download the file but it just cant be opened. The download code appears to
work fine as far as logging the user and sending the file (as far as i can
tell) but my guess is that there is a problem with the download tracker that
is corrupt ing the file because the file is fine onmy local drive. Any
ideas?
Thanks,
Ashok
Code posted below.
Sub DownloadFile(ByVal forceDownload As Boolean)

Dim productcode As String =
HttpContext.Current.Request.QueryString("ProductCo de").ToString

Dim productpath As String

Dim ds As DataSet = dal.ExecuteDataset(dal.RDConn, CommandType.Text, "Select
* From Products Where ProductCode=@ProductCode", "Products", New
OleDb.OleDbParameter("@ProductCode", productcode))

Dim fp As String = ds.Tables(0).Rows(0).Item("ProductPath").ToString

Dim name As String = Path.GetFileName(fp)

Dim ext As String = Path.GetExtension(fp)

dal.ExecuteNonQuery(dal.RDConn, CommandType.Text, "Update Products Set
ProductDownloadCount=ProductDownloadCount + 1 Where
ProductCode=@ProductCode", New OleDbParameter("@ProductCode",
productcode.ToString))

dal.ExecuteNonQuery(dal.RDConn, CommandType.Text, "Insert Into
ProductDLCount (ProductName, ProductCode,DateDownloaded, IPAddress) Values
(@ProductName, @ProductCode, @Date, @IPAddress)", New
OleDbParameter("@ProductName", name.ToString), New
OleDbParameter("@ProductCode", productcode), New OleDbParameter("@Date",
DateTime.Now.ToString("F")), New OleDbParameter(" @IPAddress",
HttpContext.Current.Request.UserHostAddress.ToStri ng))

Dim type As String = ""

' set known types based on file extension

If Not (ext Is Nothing) Then

Select Case ext.ToLower()

Case ".htm", ".html"

HttpContext.Current.Response.ContentType = "text/HTML"

Case ".txt"

HttpContext.Current.Response.ContentType = "text/plain"

Case ".doc", ".rtf"

HttpContext.Current.Response.ContentType = "application/msword"

Case ".zip"

HttpContext.Current.Response.ContentType = "application/zip"

Case ""

HttpContext.Current.Response.ContentType = "application/octet-stream"

End Select

End If

If forceDownload Then

HttpContext.Current.Response.AppendHeader("content-disposition",
"attachment; filename=" + name)

End If

If type <> "" Then

HttpContext.Current.Response.ContentType = type

End If

HttpContext.Current.Response.WriteFile(fp)

HttpContext.Current.Response.End()

Nov 18 '05 #1
0 1308

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

5
by: Brandon Walters | last post by:
I wrote a file download module for my website. The reason for the file download module is that my website downloads work on a credit based system. So I need to keep track of and limit daily...
2
by: RickL | last post by:
I have an ASP application that uploads a specified file to the server. To retrieve the file, I simply assign the filepath and file to a hyperlink on the page. When you click "Save Target As" for...
1
by: Charlie | last post by:
Hi: I'm uploading documents into a SQL Server Image field and using Response.BinaryWrite() to download or view them in the browser. Some doc types like Adobe Illustrator and Photoshop files...
5
by: Neil Rossi | last post by:
I have an issue with a particular ASP page on two web servers. Let's call these servers Dev1 and Beta1. Both Servers are running IIS 5, Windows 2000 SP4 with "almost" all of the latest patches. ...
7
by: eventuranza | last post by:
For my application, there users can upload and download files to the a webserver. Straightforward enough. However, when they upload a PDF file then try to download it, the file seems to be...
0
by: Muhammad Zeeshan Iqbal | last post by:
Hello, Language= Java; Platform= Linux; Application= Web I have help excel file. I download it using FileInputStream. When it is downloaded from solaris or widows platform it is correct....
0
by: Dom Rout | last post by:
Hello. Well, this is my first post on any USENET group anywhere, so I hope I get it right. Basically, I just want to get some opinions on a plan of mine for a new project. I want to produce a...
4
by: nitupatra | last post by:
I have perl script which will make a zip file and create a HTML form with asubmit button to send the zip file client. When user click the download button the zip file will be downloaded. But the...
5
by: rubelbd | last post by:
I have face the problem When download .doc file this is corrupted Please Help me. my code is : String FileName = Request.QueryString; StreamReader sr = new...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.