This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMemoryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:
Please help me to find the solution to run this code properly in windows
services as well.
using Xceed.Compression;
using Xceed.FileSystem;
using Xceed.Zip;
Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";
public int MakeZipFile(string zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}
catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}
}
// Windows Services --- main part of execution
string zipfilepath="C:\\temp\\pollNew.zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\121807\\00007069.FCI";
pFiles[1]="D:\\New\\121807\\00007069.FI2";
pFiles[2]="D:\\New\\121807\\00007069.FIM";
pFiles[3]="D:\\New\\121807\\00007069.IDX";
pFiles[4]="D:\\New\\121807\\00007069.RCI";
pFiles[5]="D:\\New\\121807\\00007069.RI2";
pFiles[6]="D:\\New\\121807\\00007069.RIM";
MakeZipFile(string zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here 5 2272
"vishruth" <vi******@discussions.microsoft.comwrote in message
news:A5**********************************@microsof t.com...
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMemoryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:
Please help me to find the solution to run this code properly in windows
services as well.
using Xceed.Compression;
using Xceed.FileSystem;
using Xceed.Zip;
Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";
public int MakeZipFile(string zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}
catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}
}
// Windows Services --- main part of execution
string zipfilepath="C:\\temp\\pollNew.zip"; // all my image files will
be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\121807\\00007069.FCI";
pFiles[1]="D:\\New\\121807\\00007069.FI2";
pFiles[2]="D:\\New\\121807\\00007069.FIM";
pFiles[3]="D:\\New\\121807\\00007069.IDX";
pFiles[4]="D:\\New\\121807\\00007069.RCI";
pFiles[5]="D:\\New\\121807\\00007069.RI2";
pFiles[6]="D:\\New\\121807\\00007069.RIM";
MakeZipFile(string zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Don't ever assume you have that huge block of free memory available in a
32-bit process. The fact that it works in a Windows program (say you were
lucky) doesn't mean it will work in another kind of application, note that
it's even possible that it will work all the time in your Windows
application one small change can easily spoil the party. If you need to make
sure that your memory demand as a chance to succeed, you'll have to
instantiate the MemoryFailPoint class from System.Runtime (assumes V2 of the
framework) before you initiate the memory consuming operation. Of course
this will need you to know the exact amount of memory needed for the
operation to succeed.
That said, I'm not entirely clear on why you need to run this from a Windows
Service, people tend to think that everything needs to run in the background
without even thinking about the complexities that come with developing
Services.
Willy.
As Willy pointed out, perhaps you do not need a Windows Service. If what you
need to do is make regular backups of images into a zip file, why not just
code it as a Console app and have Task Scheduler run it 1x a day?
-- Peter
Site: http://www.eggheadcafe.com
UnBlog: http://petesbloggerama.blogspot.com
MetaFinder: http://www.blogmetafinder.com
"vishruth" wrote:
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMemoryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:
Please help me to find the solution to run this code properly in windows
services as well.
using Xceed.Compression;
using Xceed.FileSystem;
using Xceed.Zip;
Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";
public int MakeZipFile(string zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}
catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}
}
// Windows Services --- main part of execution
string zipfilepath="C:\\temp\\pollNew.zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\121807\\00007069.FCI";
pFiles[1]="D:\\New\\121807\\00007069.FI2";
pFiles[2]="D:\\New\\121807\\00007069.FIM";
pFiles[3]="D:\\New\\121807\\00007069.IDX";
pFiles[4]="D:\\New\\121807\\00007069.RCI";
pFiles[5]="D:\\New\\121807\\00007069.RI2";
pFiles[6]="D:\\New\\121807\\00007069.RIM";
MakeZipFile(string zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Thank you for your suggestion Willy, but at the same time, I am helpless,
that I have to run it only with windows services, as my company demands that.
Can u justify me that if the same code for zipping image files about 900mb
works with windows application,why doesnt it work with windows services.
But the same code in windows services works for lower MB files but if it
crosses say about 250 MB then I face this problem "System OutOfMemory
Exception".
If u can share your thoughts with me, I could pass on the same to the person
who assigned me this task.
It will be of gr8 help,then.
Thanks,
Vishruth
"vishruth" wrote:
This code works fine in Windows Application.
In Windows Application, I am able to zip the image files properly and it
totally contains 900MB
My problem is the same code which I used in my Windows Application,
does not work while I run it with Windows services.
In my Windows application I am able to zip the whole 900Mb without any
problems,
but in my windows services I am not able to zip the whole 900Mb.
In Windows Services it throws an error :SystemOutOfMemoryException
I am trying to zip all image files, example: idx,fim,rim
Below is the code I am using:
Please help me to find the solution to run this code properly in windows
services as well.
using Xceed.Compression;
using Xceed.FileSystem;
using Xceed.Zip;
Xceed.Zip.Licenser.LicenseKey = "ZINxx-xxxxx-xxxxx-xxxx";
public int MakeZipFile(string zipFileName, string[] filesToComp)
{
int retVal = 0;
DiskFolder tempFolder = new DiskFolder();
try
{
ZipArchive zip = new ZipArchive( new DiskFile( zipFileName ) );
zip.TempFolder = tempFolder;
try
{
zip.BeginUpdate();
foreach( string file in filesToComp )
{
DiskFile fileToZip = new DiskFile( file );
fileToZip.CopyTo( zip, true );
++retVal;
}
}
finally
{
zip.EndUpdate();
}
}
catch(Exception exec)
{
throw new ZipException(exec.Message);
}
finally
{
}
return retVal;
}
}
}
// Windows Services --- main part of execution
string zipfilepath="C:\\temp\\pollNew.zip"; // all my image files will be
zipped in pollnew.zip
string[] pFiles=new string[7]; // pFiles contains all files
that I want to zip
pFiles[0]="D:\\New\\121807\\00007069.FCI";
pFiles[1]="D:\\New\\121807\\00007069.FI2";
pFiles[2]="D:\\New\\121807\\00007069.FIM";
pFiles[3]="D:\\New\\121807\\00007069.IDX";
pFiles[4]="D:\\New\\121807\\00007069.RCI";
pFiles[5]="D:\\New\\121807\\00007069.RI2";
pFiles[6]="D:\\New\\121807\\00007069.RIM";
MakeZipFile(string zipfilepath, string[] pFiles) // calling MakeZipFile
Function Here
Is it possible that the zip library you are using is being
unnecessarily hungry here? I'm not familiar with the product (although
I recognise the name).
Off the wall, but have you tried the free but well-truested
sharpziplib? (and yes, I did notice that xceed sponsor icsharpcode).
(if you do, be sure to use a fixed size buffer; don't attempt to read
the entire source file at once).
Marc
For illustration, the following (using #ziplib) handles multi-hundred-
megabite files with a very small memory footprint - worth giving it a
whirl? (you might be able to further optimise it with some bespoke
buffer code).
using System;
using ICSharpCode.SharpZipLib.Zip;
class Program {
static void Main(string[] args) {
using (ZipFile zip = ZipFile.Create(args[0])) {
zip.BeginUpdate();
for(int i = 1; i <args.Length; i++) {
zip.Add(args[i]);
}
zip.CommitUpdate();
zip.Close();
}
}
}
Marc This thread has been closed and replies have been disabled. Please start a new discussion. Similar topics
by: bob |
last post by:
I have created a simple Windows service in VB.Net which installs fine
using InstallUtil.exe to install it to, for example "c:\test", or
"c:\Windows\YellowBanana", but if I install it to "c:\Program...
|
by: Jay |
last post by:
Hello,
I have Windows Forms application which uses MS Access Database and a Pocket
PC application which uses Datasets, Iam trying to pass Datasets between
these applications using WebServices. ...
|
by: pepcag |
last post by:
I used
http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpguide/html/cpconalteringsoapmessageusingsoapextensions.asp
as a template to create a very simple web method with soap...
|
by: graciezzzzz |
last post by:
Hi all,
I create a Web Service project called 'eSelectService' and another Class
Library project called 'MonerisVO', and a Windows Form project called 'maps'
as well.
The reason why I need...
|
by: Stacey Levine |
last post by:
I have a webservice that I wanted to return an ArrayList..Well the service
compiles and runs when I have the output defined as ArrayList, but the WSDL
defines the output as an Object so I was...
|
by: Kevin D. |
last post by:
Please note, I already posted this on the MySQL official forum, but received
no response. I thought I'd try again in another location. My apologies to
anyone reading this twice...
Despite...
|
by: Suresh |
last post by:
Hi Guys
I have Db2 server installed on remote server. i am connecting to that
remote server by using VPN.
I want to connect that remote DB2 server instance using my local
machine DB2...
|
by: Suresh |
last post by:
Hi Guys
I have Db2 server installed on remote server. i am connecting to that
remote server by using VPN.
I want to connect that remote DB2 server instance using my local
machine DB2...
|
by: =?Utf-8?B?aGVsZmk=?= |
last post by:
Hi all,
I have replied with my own questions to an older post entry
but after a while I thought it's better to start a new thread based on
the previous one. Perhaps with the new thread I will...
|
by: Faith0G |
last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome former...
|
by: ryjfgjl |
last post by:
In our work, we often need to import Excel data into databases (such as MySQL, SQL Server, Oracle) for data analysis and processing. Usually, we use database tools like Navicat or the Excel import...
|
by: taylorcarr |
last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
|
by: Charles Arthur |
last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
|
by: ryjfgjl |
last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
|
by: emmanuelkatto |
last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud.
Please let me know.
Thanks!
Emmanuel
|
by: nemocccc |
last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
|
by: Sonnysonu |
last post by:
This is the data of csv file
1 2 3
1 2 3
1 2 3
1 2 3
2 3
2 3
3
the lengths should be different i have to store the data by column-wise with in the specific length.
suppose the i have to...
| |