Jump to content


Photo

worked in emulator but fails in the device.

- - - - -

  • Please log in to reply
No replies to this topic

#1
aruna

aruna

    Newbie

  • Members
  • Pip
  • 7 posts
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 by aruna, 07 February 2008 - 04:57 PM.

  • 0




0 user(s) are reading this topic

0 members, 0 guests, 0 anonymous users