|
Hi,
To reduce the memory consumption :
1- Use the jpeg format
2- Specify the compression level
3- Always dispose graphics objects, pens, images,.. and set them to null
Here some code to specify the compression level :
private static ImageCodecInfo GetEncoderInfo(String mimeType)
{
int j;
ImageCodecInfo[] encoders;
encoders = ImageCodecInfo.GetImageEncoders();
for(j = 0; j < encoders.Length; ++j)
{
if(encoders[j].MimeType == mimeType)
return encoders[j];
}
return null;
}
private void SaveJPGWithCompressionSetting( Image image, string szFileName, long lCompression )
{
EncoderParameters eps = new EncoderParameters(1);
eps.Param[0] = new EncoderParameter( Encoder.Quality, lCompression );
ImageCodecInfo ici = GetEncoderInfo("image/jpeg");
image.Save( szFileName, ici, eps );
}
|
|
|
|
|
I have a program it contains 7 dll files and 1 exe files.
but i see dll files can be used by other developer by adding referance. How could i restrict this? Or could i add files to Exe ?
|
|
|
|
|
Hi,
if all your source code uses the same language (say C#) you can organize it all in one project, resulting in one exe file, zero dll files.
The main reason for dll files is to support reuse (either Controls that can be added
to Visual's toolbox, or general classes e.g. for numeric algorithms, graphic library,
encryption, whatever). Once you have the dll, and some knowledge about it, you can
create new projects that make good use of it. And so can others.
A secondary reason to use dll files is for mixing languages (say C# and VB.NET).
If you want to protect your intellectual property, putting it all in a single exe is
only a small improvement, since .NET byte codes can be decompiled with tools such as
Reflector, wheter in dll or in exe.
|
|
|
|
|
Thanx
i added all dll source code into main project.
I created this dll files to reuse just by me. but i cannot allow this files can be used by someone. I mean
how could i restrict this?
adding Strong key is a solution?
or GUID number?
or what is the best solution.
|
|
|
|
|
Hi,
I dont really know; you can make it more difficult for others to use a dll, by giving
it a complex API, with methods that need to be called in a specific order, with
extra arguments that must match some criterium, etc, but using a tool such as Reflector
one can always see how you do it.
A strong key will not help, it is intended to prevent someone to use a different
dll underneath your exe in order to falsify your app. That's not what you are after is it ?
|
|
|
|
|
I'm writing a multithreaded application, and in some phase in my program i have to add
a row to the datagridview control from thread other than the thread the control created
in, but when using this line of code
Control.CheckForIllegalCrossThreadCalls = false;
when the rows count comes out of the datagridview control visible area,and then try to
add a row the program stuck on screen (NotResponding).
so i want to know how to call an invoke method on a datagridview control to add a row?
in order to make the call a thread safe.
thanks in advance,
|
|
|
|
|
Hi,
the InvokeRequired property and Invoke/BeginInvoke methods work the same on all controls,
you can find many articles about that subject.
Both of my articles also show a very simple example; I recommend you look at MainForm.cs
in the Sokoban article.
You must follow the rules here; if you dont, it may or may not work on .NET 1.x
(not work here means freeze); on .NET 2.0 and above, it will throw an exception.
|
|
|
|
|
|
Hi, I keep getting the error "The requested URI is invalid for this FTP command." when trying to upload a file from local machine to the FTP server using code below in C# 2.0. I am getting error on the bold line below.
I would appreaciate if someone can guide me to proper solution.
thanks
Mahesh
public void Deliver()
{
FtpWebRequest request = (FtpWebRequest)WebRequest.Create(destinationHost); //destination host is ftp://actual IP address/
request.Method = WebRequestMethods.Ftp.UploadFile;
request.Credentials = new NetworkCredential(userId, password);
// Copy the contents of the file to the request stream.
StreamReader sourceStream = new StreamReader(sourceDirectory + sourceFile);
byte[] fileContents = Encoding.UTF8.GetBytes(sourceStream.ReadToEnd());
sourceStream.Close();
request.ContentLength = fileContents.Length;
Stream requestStream = request.GetRequestStream(); //getting error here stating requested uri is invalid for this FTP commnand.
requestStream.Write(fileContents, 0, fileContents.Length);
requestStream.Close();
FtpWebResponse response = (FtpWebResponse)request.GetResponse();
Console.WriteLine("Upload File Complete, status {0}", response.StatusDescription);
response.Close();
}
Thanks
Needy
|
|
|
|
|
First,I'd like to thank you for this great effort
how can I shutdown and restart my computer from my app
Dad
|
|
|
|
|
Hi.
You can use WindowsController class, which you can find here: http://www.mentalis.org/soft/class.qpx?id=7
It's really easy to use, for example to shutdown your computer, just write:
WindowsController.ExitWindows(RestartOptions.ShutDown, false);
In file with this class, you'll find simple example.
-- modified at 16:58 Thursday 1st March, 2007
|
|
|
|
|
Hi,
the single-line solution is:
System.Diagnostics.Process.Start("Shutdown", "/s"); // shutdown
System.Diagnostics.Process.Start("Shutdown", "/r"); // restart
/
|
|
|
|
|
|
Hi all,
I am new to c#, learning lots iof new things everday!
I would like help with a simple function, what few lines of code do i need in order to do the following:
A String is passed into the function as parameter (string s), what would i need to add in the function for the number of words to be counted in that string and the result returned as a integer?? any ideas
I know its a simple thing, but im new and would like some help.
Cheers
|
|
|
|
|
This should do the trick:
inputString.Split(" ").Length
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
it.all,depends;on_the_definition of a'word'.
|
|
|
|
|
Luc Pattyn wrote: it.all,depends;on_the_definition of a'word'.
Very clever.
|
|
|
|
|
for example, if the string is:
"programming is great"
the result would be 3. i.e. 3 words
hope this helps.
Cheers
|
|
|
|
|
Sure, but what about:
r.s.v.p. 0, 1 or 4 words ?
I don't know 3 or 4 words ?
that's really great 3 or 4 words ?
is programming great ? 3 or 4 words ?
three words here 3 or 4 words ? (double space used!)
So you really must specify in detail ... What constitutes a word, how do you
recognize its begin and end, how do you treat composite words, what with abreviations, etc.
BTW: I would say r.s.v.p. is five words (repondez s'il vous plait).
-- modified at 15:43 Thursday 1st March, 2007
|
|
|
|
|
Luc Pattyn wrote: it.all,depends;on_the_definition of a'word'.
Good point. I count three
"Programming today is a race between software engineers striving to build bigger and better idiot-proof programs, and the Universe trying to produce bigger and better idiots. So far, the Universe is winning." - Rick Cook www.troschuetz.de
|
|
|
|
|
Hi,
Here your function (I presume that each two words are separated with a space) :
public int GetWordsCount(string s)
{
if (s==null)
return 0;
string trimmedString = s.Trim(); // To remove spaces at the begin/end
string[] words = trimmedString.Split(' ');
return words.Length;
}
|
|
|
|
|
I have a client/server application written in C#, i use TCPCLient and TCPListener methods to establish the connection.
I want add an HTTP Tunnel at my application to bypass my firewall, on my system i have a software firewall (Sygate Personal Firewall), i don't use a router and proxy server to access the net.
How, i can use HTTP Tunnel to bypass my firewall software whit my program?
Thank?
|
|
|
|
|
1) Disable the software firewall.
or
2) Enable a DMZ in the firewall for your app that maps the ports.
File Not Found
|
|
|
|
|
Thanks, but i want to find a solution to bypass my firewall without disable it or to map the ports.
A solution software, tunneling etc...
|
|
|
|
|
Well considering the job of the firewall is to block access ...
Download an SSH server and an SSH client. Find a port which the firewall will let you use and then you can use SSH to tunnel.
File Not Found
|
|
|
|