Click here to Skip to main content
15,898,687 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
AnswerRe: MOSS 2007 help required Pin
Saurav Jaiswal9-Dec-08 0:47
Saurav Jaiswal9-Dec-08 0:47 
QuestionConsole Application Help Pin
Dan Suthar4-Dec-08 1:31
professionalDan Suthar4-Dec-08 1:31 
AnswerRe: Console Application Help Pin
Wendelius4-Dec-08 9:46
mentorWendelius4-Dec-08 9:46 
GeneralRe: Console Application Help Pin
Dan Suthar4-Dec-08 20:28
professionalDan Suthar4-Dec-08 20:28 
GeneralRe: Console Application Help Pin
Dave Kreskowiak5-Dec-08 3:28
mveDave Kreskowiak5-Dec-08 3:28 
AnswerRe: Console Application Help Pin
Dan Suthar5-Dec-08 5:53
professionalDan Suthar5-Dec-08 5:53 
GeneralRe: Console Application Help Pin
Wendelius5-Dec-08 7:55
mentorWendelius5-Dec-08 7:55 
QuestionException handling Pin
Umangj3-Dec-08 15:34
Umangj3-Dec-08 15:34 
I m trying to open a zip file selected by user and extracting it....
It runs fine for the first time but when i again clicks on the open file button and selects a zip file. It throws an exception:

The process cannot access the file "file.png" because it is being used by another process
Note: file.png being one of the files extracted from the .zip file.

I think the FileStream object is not releasing the file after opening it. I tried using f.Destroy() and f.close() but they didnt work. Also the code runs for the first time successfully and it creates an error when another .zip file is opened (using the openfiledialog box) after opening the first file successfully.

String filename = openFileDialog1.FileName;
                
                ZipInputStream zis = null;

                FileStream f = new FileStream(filename, FileMode.Open);
                
                zis = new ZipInputStream(f );
                ZipEntry ze=null;
                while ((ze = zis.GetNextEntry()) != null)
                {
                    FileStream fs = null;
                    fs =System.IO.File.Create("d:\\puzzlesolver\\pieces\\"+ze.Name);
                    int size = 2048;
                    byte[] data = new byte[2048];
                    
                    while (true)
                    {
                        
                        size = zis.Read(data, 0, data.Length);
                        if (size > 0)
                        {
                            fs.Write(data, 0, size);
                        }
                        else
                        {
                            break;
                        }
                    }

                    fs.Close();
                }
                //f.Flush();
                f.Close();
                f.Dispose();
                zis.Close();
                zis.Dispose();

GeneralRe: Exception handling Pin
Luc Pattyn3-Dec-08 16:08
sitebuilderLuc Pattyn3-Dec-08 16:08 
GeneralRe: Exception handling Pin
Umangj3-Dec-08 17:45
Umangj3-Dec-08 17:45 
QuestionPointers and arrays problem Pin
Boo102-Dec-08 19:28
Boo102-Dec-08 19:28 
AnswerRe: Pointers and arrays problem Pin
Simon P Stevens2-Dec-08 23:00
Simon P Stevens2-Dec-08 23:00 
GeneralRe: Pointers and arrays problem Pin
Paul Conrad3-Dec-08 4:48
professionalPaul Conrad3-Dec-08 4:48 
AnswerRe: Pointers and arrays problem Pin
Paul Conrad3-Dec-08 4:49
professionalPaul Conrad3-Dec-08 4:49 
NewsReceive Windows 7 Beta 1 at a Local MSDN Developer Conference Pin
concordmfg2-Dec-08 12:24
concordmfg2-Dec-08 12:24 
QuestionNotSupportedException Pin
Developer6112-Dec-08 10:16
Developer6112-Dec-08 10:16 
AnswerRe: NotSupportedException Pin
Dave Kreskowiak2-Dec-08 10:41
mveDave Kreskowiak2-Dec-08 10:41 
GeneralRe: NotSupportedException Pin
Member 53148902-Dec-08 18:40
Member 53148902-Dec-08 18:40 
GeneralRe: NotSupportedException Pin
Dave Kreskowiak3-Dec-08 1:46
mveDave Kreskowiak3-Dec-08 1:46 
QuestionDynamic picturebox allocation Pin
Umangj2-Dec-08 8:08
Umangj2-Dec-08 8:08 
QuestionPls Reply guyz Pin
Umangj3-Dec-08 2:43
Umangj3-Dec-08 2:43 
AnswerRe: Pls Reply guyz Pin
Paul Conrad3-Dec-08 4:52
professionalPaul Conrad3-Dec-08 4:52 
AnswerRe: Dynamic picturebox allocation Pin
Gideon Engelberth3-Dec-08 3:20
Gideon Engelberth3-Dec-08 3:20 
GeneralRe: Dynamic picturebox allocation Pin
Umangj3-Dec-08 15:35
Umangj3-Dec-08 15:35 
QuestionVB6 to VB.NET - DLL function arguments conversion Pin
boris.sclauzero2-Dec-08 6:00
boris.sclauzero2-Dec-08 6:00 

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.