Click here to Skip to main content
14,423,188 members

.NET Framework

 
PinnedHOW TO ANSWER A QUESTION Pin
Chris Maunder16-Jul-09 4:09
cofounderChris Maunder16-Jul-09 4:09 
PinnedHow to get an answer to your question Pin
Chris Maunder16-Jul-09 4:05
cofounderChris Maunder16-Jul-09 4:05 
QuestionGetting Error System.IO.InvalidDataException: 'End of Central Directory record could not be found Pin
simpledeveloper2-Jan-20 9:10
Membersimpledeveloper2-Jan-20 9:10 
I have method which was working fine with PDFs has started giving errors, I checked in TFS - I didn't find any changes in that part of the method, I am getting the error: System.IO.InvalidDataException: 'End of Central Directory record could not be found.', but the PDF is valid and other clients told me it has started throwing errors for the pdfs previously were working. Here is the code:
try
                {
                    using (MemoryStream ms = new MemoryStream(fileData))
                    {                        
                        List<string> dangerous_files = new List<string>();
                        string msgModel = "ZIP: {zip} - ({file})";
                        using (ZipArchive archive = new ZipArchive(ms))
                        {
                            foreach (var entity in archive.Entries)
                            {
                                if (denyExtensions.Contains(entity.FullName.Split('.').LastOrDefault().ToLower()))
                                {
                                    dangerous_files.Add(msgModel.Replace("{zip}", GetRidOfSlash(file.FileName)).Replace("{file}", entity.FullName));
                                }
                            }
                            if (dangerous_files.Count > 0)
                            {
                                Response.TrySkipIisCustomErrors = true; Response.StatusCode = 500;
                                return Json(new
                                {
                                    error = errMsg,
                                    code = "500.1",
                                    files = dangerous_files
                                });
                            }
                        }
                    }
                }
                catch (Exception ex)
                {
                    LogHandler.LogError(4203, "Zip file creation failed Upload - Picture", ex);
                    throw ex;
                }

The place where I am getting the errors is at the following line:
using (ZipArchive archive = new ZipArchive(ms))

Any help would be very very helpful - thanks in advance.
AnswerRe: Getting Error System.IO.InvalidDataException: 'End of Central Directory record could not be found Pin
Eddy Vluggen2-Jan-20 11:29
mveEddy Vluggen2-Jan-20 11:29 
AnswerRe: Getting Error System.IO.InvalidDataException: 'End of Central Directory record could not be found Pin
Richard MacCutchan2-Jan-20 22:55
communityengineerRichard MacCutchan2-Jan-20 22:55 
QuestionMessage Closed Pin
31-Dec-19 20:09
Memberlinden george31-Dec-19 20:09 
Questionwhat is tuple in mvc Pin
Anil Sharma198326-Dec-19 6:29
professionalAnil Sharma198326-Dec-19 6:29 
AnswerRe: what is tuple in mvc Pin
Pete O'Hanlon26-Dec-19 7:38
communityengineerPete O'Hanlon26-Dec-19 7:38 
AnswerRe: what is tuple in mvc Pin
Eddy Vluggen26-Dec-19 12:42
mveEddy Vluggen26-Dec-19 12:42 
QuestionSharpGL control on MDI Childwindow: Childwindow not sizable with mouse Pin
Member 1433546425-Dec-19 6:48
MemberMember 1433546425-Dec-19 6:48 
QuestionHow to get connection string of server and connect to it? Pin
SebGM2521-Dec-19 7:01
MemberSebGM2521-Dec-19 7:01 
AnswerRe: How to get connection string of server and connect to it? Pin
Eddy Vluggen21-Dec-19 11:38
mveEddy Vluggen21-Dec-19 11:38 
QuestionMessage Closed Pin
20-Dec-19 23:51
Memberbaba ntanzi20-Dec-19 23:51 
QuestionRichTextBox Viewer Pin
Diex196819-Dec-19 5:25
MemberDiex196819-Dec-19 5:25 
AnswerRe: RichTextBox Viewer Pin
Eddy Vluggen21-Dec-19 11:41
mveEddy Vluggen21-Dec-19 11:41 
GeneralRe: RichTextBox Viewer Pin
Gerry Schmitz22-Dec-19 4:24
mveGerry Schmitz22-Dec-19 4:24 
GeneralRe: RichTextBox Viewer Pin
Diex196822-Dec-19 8:08
MemberDiex196822-Dec-19 8:08 
QuestionGet list from list of elements link and collections Pin
simpledeveloper13-Dec-19 7:13
Membersimpledeveloper13-Dec-19 7:13 
AnswerRe: Get list from list of elements link and collections Pin
Richard Deeming13-Dec-19 7:29
communityengineerRichard Deeming13-Dec-19 7:29 
GeneralRe: Get list from list of elements link and collections Pin
simpledeveloper13-Dec-19 9:24
Membersimpledeveloper13-Dec-19 9:24 
QuestionThe operation failed: The relationship could not be changed because one or more of the foreign-key - EF Code first Pin
simpledeveloper6-Dec-19 7:45
Membersimpledeveloper6-Dec-19 7:45 
AnswerRe: The operation failed: The relationship could not be changed because one or more of the foreign-key - EF Code first Pin
Gerry Schmitz6-Dec-19 8:29
mveGerry Schmitz6-Dec-19 8:29 
GeneralRe: The operation failed: The relationship could not be changed because one or more of the foreign-key - EF Code first Pin
simpledeveloper6-Dec-19 8:52
Membersimpledeveloper6-Dec-19 8:52 
GeneralRe: The operation failed: The relationship could not be changed because one or more of the foreign-key - EF Code first Pin
simpledeveloper9-Dec-19 10:12
Membersimpledeveloper9-Dec-19 10:12 
GeneralRe: The operation failed: The relationship could not be changed because one or more of the foreign-key - EF Code first Pin
simpledeveloper9-Dec-19 15:40
Membersimpledeveloper9-Dec-19 15:40 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.