|
Why do you need the ToString and the byte.Parse, are they not both doing stuff that is completely superfluous ?
255 ^ buffer[i]
would do it, I'd have thought. ^ == XOR
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Thanks I will try out later and see what happens
|
|
|
|
|
Christian Graus wrote: 255 ^ buffer[i]
would do it, I'd have thought. ^ == XOR
Or using the ^= operator:
buffer[i] ^= 255;
Subtracting the value from 255 gives the same result, only the calculation is done using integers, so you would have to cast the result to byte (I guess that's the intention of the ToString and Parse in the original code):
buffer[i] = (byte)(255 - buffer[i]);
---
single minded; short sighted; long gone;
|
|
|
|
|
well this is what I tried and it worked
buffer[i] = (byte)(255 ^ buffer[i]);
and for some reseon I still have to cast it
and the results are incredibly fast
From about 7 Minutes to a half a minute, on about a 600MB File
Thanks all for your help
(I just started playing around with the Streams)
|
|
|
|
|
This is my results in seconds
^= 31, 28, 27, 26, 29, 27, 25
cast - 28, 25, 25, 25, 26, 25, 26
cast ^ 30, 26, 26, 25, 26, 26, 26
|
|
|
|
|
F16I wrote: br.Read(buffer, 0, 5000000);
Warning! The Read method returns how many bytes that was actually read, and that doesn't have to be all the bytes that are possible to read. You have to get the return value of the call so that you know if you need more calls to read the rest of the file. Just loop until the method returns zero, that means that there are no more bytes to read.
If you use framework 2, you can use the File.ReadAllBytes method to read the entire file.
---
single minded; short sighted; long gone;
|
|
|
|
|
I just put thet in as an example, just wanted to show a long array
|
|
|
|
|
I think that you missed the point.
If you call the Read method without checking what it returns, it may read only part of the file without you realising it, and you will merrily continue, believing that the entire file is in the array while in fact part of the data is just garbage.
---
single minded; short sighted; long gone;
|
|
|
|
|
I know, (it is inside a for loop) and by the way I am not trying to XOR the whole file, but anyway "thanks vary much for your help"
|
|
|
|
|
I can't figure out the RegEx I need to get this done.
I am pulling data off a web page and am trying to get the following.
Rank: 12,653
Name: Nosferatu
Level: 11
Money: 50,727,875
Bank: 0
From this section of the webpage, although I am passing the whole webpage at one time.
<tr>
<td align="center">12,653</td>
<td ><a href="profile.php?id=216816">Nosferatu</a></td>
<td align="center">11</td>
<td >$50,727,875</td>
<td >$0</td>
</tr>
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
expresso is the subject of an article on CP, I think, and it's certainly at www.expresso.com. It's an invaluable tool for working out regex. In this case, it looks like you could use string mashing, although it depends what the rest of the page is, and how static this format is.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Christian Graus wrote: It's an invaluable tool for working out regex.
No kidding. Wish I would have ran across it when I took an Automata course some years ago
"too much daily WTF for someone..." - Anton Afanasyev
|
|
|
|
|
The page is comprised of 100 of these. Its a table. It is consistant as well. I'll look into string mashing if you think it will work.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
The hard part is finding the snippet of text that contains the values you're looking for.
RegEx does give you capture, so it could be better.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
Expresso was amazing thanks man.
Christian Graus wrote: and it's certainly at www.expresso.com
It's actually not at that website. I had to Google for it.
Thanks.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Hi,
I have a form that there's many button on it. when I press each button a usercontrol appear.
there's a button on every usercontrol that use for closing the usercontrol.
Now,I do not know how I should close the usercontrol.
Do you know its code?????
thanks
|
|
|
|
|
A user control doesn't get closed, typically. It is more likely to get hidden, there's a Visible property you can set to false.
Christian Graus - Microsoft MVP - C++
Metal Musings - Rex and my new metal blog
"I am working on a project that will convert a FORTRAN code to corresponding C++ code.I am not aware of FORTRAN syntax" ( spotted in the C++/CLI forum )
|
|
|
|
|
i need whern click or double click datagrid clouumnheader to reterive this column number to select or deseclect all sells in that column
thanks
md_refay
|
|
|
|
|
Hi, im using a singelton pattern to ensure that only one innstance of a winfrom can be opened at one time. The problem im having is when I close the form and want to open it again I get a "Cannot access a disposed object." How can I solve this? //thx
|
|
|
|
|
Hi,
if you want to see the same instance of your form class again, you should hide
it instead of closing it; so use Form.Hide() or Form.Visible=false
|
|
|
|
|
Thx, but I don't want to show the same instance of the form. I wan't to be able to create a new instance but only have one open at the same time.
|
|
|
|
|
I think you need to show some code, with form creation, Dispose, your current'
singleton stuff, etc.
And what should (not) cause the creation of a new form ?
|
|
|
|
|
So some samplecode then. when the user clicks the button the new form opens. He should not be able to open any more forms of this type unless he closes the form.
inside main form:
private void button1_Click(object sender, EventArgs e)
{
Form2 form = Form2.Instance();
form.Show();
}
inside form2:
private static Form2 instance;
public static Form2 Instance()
{
if (instance == null)
{
instance = new Form2();
}
return instance;
}
protected Form2()
{
}
|
|
|
|
|
Hi,
from your code it is apparant you implemented a singleton: initially there
is no instance of Form2; once you call Form2.Instance, there is exactly one.
If you call Form2.Instance again, you get the same instance.
This is not what you want for two reasons:
- if you close the "first" Form2, it renders all future Form2 instances useless
since you can close a Form only once
- it does not prevent you from calling Form.Show() twice.
What you need instead is no singleton logic; just create a Form2 when you need one; use it; get rid of it with Close(). And add some logic to prevent two Form2
instances to coexist; possible solutions are:
- disable the button while a Form2 is visible (best, user can see it!)
- or include a test in buttonClick, something like:
private Form2 lastForm2;
if (lastForm2==null || !lastForm2.Visible) {
lastForm2=new Form2();
lastForm2.Show();
}
|
|
|
|
|
The singleton pattern is not for using one object at a time, it's for reusing the same object.
If you don't want to reuse the form instance, you should not use the singleton pattern.
---
single minded; short sighted; long gone;
|
|
|
|