Guest aruna Posted February 7, 2008 Report Posted February 7, 2008 (edited) Hi All, I have developed an application which works perfectly in my Windows Pocket 2003 emulator. After deploying into my device. Its always giving me "The process cannot access the file, as it already in use by another process." My application can work one zip file and for the second zip file its throwing that msg. My application do the following: 1) unzips the files into specific location 2) creats html and append text to html. for unzipping I am using SharpZipLib dll. Can any one please tell me how to get rid of this. I am pasting my code(which unzips the file). public void unZip_Load(System.Object sender, System.EventArgs e) { try { string zipsPath = "/My Documents"; label3.Visible = false; button1.Visible = false; DirectoryInfo di = new DirectoryInfo(zipsPath); di.Attributes = FileAttributes.Normal; FileInfo[] zFiles = di.GetFiles("*.zip"); #region foreach zipfile decompress foreach (FileInfo zFile in zFiles) { MessageBox.Show("test 2: " + "You have the {0} files in \\MyDocuments folder: " + zFiles.Length + "zip File: "+zFile.Name); string pubtitle = zFile.Name; string zipPath = zFile.FullName; string localPath = "/Programme"; string diContent = Path.Combine(localPath, "Content"); if (!Directory.Exists(diContent)) Directory.CreateDirectory(diContent); string pubtitle_val = Path.GetFileNameWithoutExtension(pubtitle); MessageBox.Show("reading file: " + zipPath); FileStream fs = new FileStream(zipPath, FileMode.Open, FileAccess.Read,FileShare.None); MessageBox.Show("reading file succeded: " + zipPath); ZipInputStream zis = new ZipInputStream(fs); MessageBox.Show("Test Test Test"); ZipEntry theEntry; while ((theEntry = zis.GetNextEntry()) != null) { string dirName = Path.GetDirectoryName(theEntry.Name); string fileName = Path.GetFileName(theEntry.Name); string serverFolder = pubsFolder + Path.DirectorySeparatorChar + pubtitle_val; if (theEntry.IsDirectory) { string serverDirectoryPath = Path.Combine(serverFolder, dirName); Directory.CreateDirectory(serverDirectoryPath); } else { if (fileName != String.Empty) { FileStream streamWriter = File.Create(serverFolder + Path.DirectorySeparatorChar + theEntry.Name); int size = 2048; byte[] data = new byte[2048]; while (true) { size = zis.Read(data, 0, data.Length); if (size > 0) { streamWriter.Write(data, 0, size); } else { break; } } streamWriter.Close(); } } } MessageBox.Show("zip is closing: " + zipPath); zis.Close(); MessageBox.Show("zip is closed successfully: " + zipPath); fs.Close(); deleteZip(zipPath); MessageBox.Show("test 2.1"); } #endregion foreach zipfile decompress getpublications(pubsFolder); label3.Visible = true; label3.Text = "Please Check the files in /Programme/Content/"; button1.Visible = true; } catch (Exception ex) { label3.Visible = true; label3.Text = ex.Message; button1.Visible = true; } } thanks Edited February 7, 2008 by aruna
Recommended Posts
Please sign in to comment
You will be able to leave a comment after signing in
Sign In Now