Click here to Skip to main content
15,891,905 members
Please Sign up or sign in to vote.
1.00/5 (2 votes)
See more:
Hi,

I have a file upload in my asp.net project and when I upload a .txt file into the database, and download them again - there is 1 character missing from the end of the file.

i.e
If I have a txt file with the alphabet, a-z, then the z will be removed.

this only happens with .txt files, Any idea why it would do this?

Thanks
Cheryl
Posted
Updated 13-Jan-11 22:42pm
v2
Comments
Sergey Alexandrovich Kryukov 12-Jan-11 12:06pm    
Did you try to debug on which step a character was removed?
Dalek Dave 14-Jan-11 4:42am    
Edited for Grammar and Readability.

I would bet that you're saving the file itself separately from the filename (that's the way I'd do it), and your problem is in the stored proc that returns the name of the file to the asp.net web site. If you're saving the filename separately from the extnsion, maybe the column that contains the filename is too small to hold the entire name.

What happens if you upload a file named "a.txt", and then download it?
 
Share this answer
 
Comments
Аslam Iqbal 12-Jan-11 14:24pm    
May the problem accessing the Index of file data. Like mid(s,e), Indexof(n) etc could be wrong. You are missing 1 byte from end.
Without code, it is difficult to tell you what is wrong, but there are four areas to look at:
1) Code to upload file.
2) Code to store file in the database.
3) Code to retrieve file from the database.
4) Code to upload the file.

To isolate which step is giving a problem, start by looking at your database content: Is the full text of the file there? If it isn't, then look at the storage code, by storing a dummy value (a known string) and seeing if it is correct. That will tell you which code to examine and / or post here.

If the database content is correct, extract the data using your existing code, and save it somewhere. Is that correct?

You will know know where you have a problem and can focus our thoughts much better when you edit your question and just the relevant code fragment.

[edit]"is" changed to "isn't" :doh: - OriginalGriff[/edit]
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900