损坏的文件的Microsoft Office 2007 ASP.NET 1.1和SQL Server [英] Corrupted Files Microsoft Office 2007 ASP.NET 1.1 and SQL Server

查看:142
本文介绍了损坏的文件的Microsoft Office 2007 ASP.NET 1.1和SQL Server的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我工作在一个ASP.NET 1.1的网站,在数据库存储文件。该网站已与上传自2001年以来下载任何类型的文件没有问题伟大的工作。

I am working on an ASP.NET 1.1 website that stores files in the database. The website has been working great with no problems uploading and downloading any type of documents since 2001.

然而,最近的客户发现,所有Microsoft Office 2007文档 DOCX XLSX ,等被损坏时,任何用户尝试下载它们。

However, recently the customer noticed that all Microsoft Office 2007 documents DOCX, XLSX, ect are corrupted when any user try to download them.

我所注意到的是,SQL Server添加一个额外的字节到 DocumentContent (image列)。上传文档之前的内容和长度都很好。然而,他们得到存储之后,SQL Server添加一个额外的字节....为什么?????

What I have noticed is that SQL Server adds an extra byte to the DocumentContent (image column). Before uploading the document the content and length are fine. However, after they get stored, SQL Server adds an EXTRA Byte.... WHY?????

很多人在互联网上提供了关于如何下载文件,这是伟大的解决方案,它为我工作。

Many people on the internet provided a solution on how to download the file, which is great and it worked for me.

我要寻找的答案......为什么SQL SERVER添加一个额外的字节到图像列?

I am looking for an answer to this question... WHY DOES SQL SERVER ADD AN EXTRA BYTE TO THE IMAGE COLUMN?

这是一个Asp.NET 1.1和SQL 2000,但是我们只是把它移动到2008年,我们仍然有同样的问题。

It is an Asp.NET 1.1 and SQL 2000 but we just moved it to 2008 and we still have the same problem.

推荐答案

我不是100%肯定,如果你的问题是一样的东西我有,但在我的情况,我发现这个问题实际上是在的一部分,而不是在阅读部分。例如,我原来写code是这样的:

I am not 100% sure if your problem was the same as what I have had but in my case, I found that the problem was actually in the writing part, not in the reading part. For example, my original writing code was like this:

Dim FILE_CONTENT(len) As Byte
File.InputStream.Read(FILE_CONTENT, 0, len)
SaveFileToDatabase(FILE_NAME, CONTENT_TYPE, FILE_CONTENT)

当我改变了第一行如下:

When I changed the first line as the following :

Dim FILE_CONTENT(0 To len - 1) As Byte 

读数误差消失。我只是忘了VB实际上默认情况下,当你标注,但没有指明下界分配N + 1个字节(O到N)。看到这里描述的类似的情况:<一href=\"http://stackoverflow.com/questions/19406990/uploaded-docx-files-are-getting-corrupted\">Uploaded docx文件越来越损坏。希望有所帮助。

这篇关于损坏的文件的Microsoft Office 2007 ASP.NET 1.1和SQL Server的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆