|
It is, I think, not even correct for sizes above 4GB.
I mean see this: (highSize << 0x20)
highSize is an int , and if you try to shift an int by 32, nothing happens, and it's only upcast after the shift.
There is just no way anyone they'd let something like this in after all the patches, so something else is going on. I went back to the reflector to check the MSIL:
L_004a: conv.i8 <--
L_004b: ldc.i4.s 0x20
L_004d: shl
edit: this must be the "offending" part of the code, it's the only place in the code where there is a shift by 0x20
So the actual code is right after all, that means it's a bug in Reflector, right? Or am I missing something?
|
|
|
|
|
1) Well spotted
2) I looked into it, and IL is OK, C# "disassembly" is wrong. Not the first bug in Reflector.
3) See, I would have used GetFileSizeEx and not have had the opportunity to make that mistake. But then it only exists since Windows Server 2000, so it would never have worked on Win98/Me .
|
|
|
|
|
Thank you all for your help. Now I got the idea and solved the problem. It would take me much longer to spot the cause by myself.
|
|
|
|
|
Now I got the idea. Thank you for your answers, this was a really hard thing to spot, for me.
|
|
|
|
|
Luc is talking about your use of fsB.Length , which is a property that you get every time. He's suggesting that you should store this and then work with that instead of fsB.Length in the loop."WPF has many lovers. It's a veritable porn star!" - Josh Smith As Braveheart once said, "You can take our freedom but you'll never take our Hobnobs!" - Martin Hughes.
My blog | My articles | MoXAML PowerToys | Onyx
|
|
|
|
|
I'm quite new to c# and dot.net. I've been scratching my head on this one for quite a while. I'm trying to build functionality similar to that shown here:
http://finviz.com/forex.ashx
I'm using the treemap code. I'm using the the text from the e.node.tooltip to disquish when the mouse hovers over a different node. I want to create a new child form that tracks the cursor like that shown in the above example. When the cursor passes over a new nodes I want to close the currently displayed form and display a new form associated with the node the mouse cursor is now hovering over. Here is were I capture the mouseover event:
void tmcMap_NodeMouseHover(object sender, NodeEventArgs e)
{
Form2 frmForm2 = new Form2();
if (e.Node.ToolTip != lastValue && frmForm2.Created != true)
{
lastValue = e.Node.ToolTip;
frmForm2.Text = "Child " + e.Node.ToolTip;
frmForm2.SetDesktopLocation(Cursor.Position.X, Cursor.Position.Y);
frmForm2.Show();
}
)
My problem is how to close frmForm2 prior to creating a new frmForm2 when the cursor hovers over a different node?
Any help would be appreciated!
|
|
|
|
|
Message Closed
modified 23-Nov-14 6:34am.
|
|
|
|
|
Thank's for the suggestion. There are a few thousand nodes in the treemap. I don't if that changes things? Also, I'm still stuck with the problem of how to make one form invisable and the next form visable when moving between nodes?modified on Friday, March 12, 2010 4:46 PM
|
|
|
|
|
Really bad idea. Creating a few thousand forms?? Seems a bit overkill.
|
|
|
|
|
Can't you do that with just the one form; hide it when not needed, make it show the data of the object of interest when hovering something. So have it invalidate when moving over another object, rather than closing one and opening another one. If doable, should be much cheaper and snappier.
|
|
|
|
|
Thank you that's a very good idea.
|
|
|
|
|
i made a remote desktop, when the client remote the server, server will be send update every time.
how to make it update every time(source code)?
thankQ..
|
|
|
|
|
I am having some problem with my c# program. The program was meant to ask a user for their age and a pin code, if the user is over 18, it ask them for their pin code and how many times they want their name displayed btw 5 and 20 but if they are not, a particular message comes up.
I am having problem setting up the variables. Do I have to store the age, pincode and numbers in int ?
This is what I have done so far and i have tried entering a wrong pin code but it didn;'t give me the messages i wanted.
class Program
{
static void Main(string[] args)
{
int age;
long pinCode;
int number;
age = 18;
pinCode = 1965;
number = 5;
What am I doing wrong?
|
|
|
|
|
Janded wrote: I am having problem setting up the variables. Do I have to store the age, pincode and numbers in int ?
You don't have to, you can store them in a string, which is how they come in from the user. However, if you what to do useful comparisons, then you do indeed need to convert them to int, long or similar.
The code below should give you the basics: Prompt, read in, convert, and show again.
class Program
{
static void Main(string[] args)
{
Console.WriteLine("Enter your age:");
string userAge = Console.ReadLine();
int age;
if (int.TryParse(userAge, out age))
{
Console.WriteLine("In ten years you will be {0}", age + 10);
}
else
{
Console.WriteLine("{0} is not a number!", userAge);
}
}
} The TryParse examines a string and attempts to convert it to an int (in this case, long, double etc. are all available). There is also Parse, but that will throw an exception if the user enters "Hello" when you want a number. TryParse doesn't - it just returns false.You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
OriginalGriff wrote: However, if you what to do useful comparisons, then you do indeed need to convert them to int, long or similar.
Not really. If you want to compare two strings you can do so.
If you want to do some arithmetic (e.g. adding 10 to age) then you need to convert to a numeric.Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
Picky, picky, picky!
I didn't want the OP to assume that string comparisons would be the most useful things he could do - and I believe in converting from string to more useful formats as early as possible, and converting back as late as possible. You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Who voted you one for that? Perfectly reasonable comment, I thought. Balance redressed as best I can... You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Your balancing caused a voting war
|
|
|
|
|
I don't really take any notice of the voting but thanks anyway.
My comment was triggered in part because I've seen horribly complex code to display the leading 0s when using numerics to store phone numbers and such like. All done in the name of saving a couple of bytes per record.
The worst was a warehouse management system (in VMS Basic) where store numbers in some files had three chars, some had integers, some longs, some four chars (with leading or trailing space) and one with six chars (commented 'For expansion'). So a simple comparison of store numbers in two files could not be done in one line. Regards
David R
---------------------------------------------------------------
"Every program eventually becomes rococo, and then rubble." - Alan Perlis
|
|
|
|
|
riced wrote: I don't really take any notice of the voting but thanks anyway.
Yeah, but a one vote implies to someone reading "this answer contains garbage" - since yours doesn't, I thought it should be corrected.
riced wrote: My comment was triggered in part because I've seen horribly complex code to display the leading 0s...
Don't you just love internal consistancy?
With telephone numbers I do tend to leave them as strings - there is no useful manipulation to do most of the time, and people do get protective of their favourite format: "+44 (0)1111 1111111" is "better" than "011111111111" and vice versa. If you can get a company wide format for these things, great - but too many will see that as the IT dept trying to "run their lives"! You can't win either way... You should never use standby on an elephant. It always crashes when you lift the ears. - Mark Wallace
C/C++ (I dont see a huge difference between them, and the 'benefits' of C++ are questionable, who needs inheritance when you have copy and paste) - fat_boy
|
|
|
|
|
Most important question:
How are you comparing the variables?
Obviously the incoming data has to be string, and not so obviously the comparison values can be stored in any format you like, however the format should be picked dependant on the data contained. So integer for a pin number may be perfect, as long as you can only have integer pin numbers.
So, show us the comparison code and we can advise you further.
|
|
|
|
|
|
Firstly, all input from Console.ReadLine or from parameters passed to the exe are strings.
Secondly, in your code you are never capturing the input, and you have your logic back to front. For starters you never prompt for the age, and also you seem to refer to the name a lot, which is also never input.
Here is an example of how the code should start, showing the logic for the input and validation of the age. Apply the same locig throughout and you are home and dry.
int age;
string input;
Console.WriteLine("Please enter your age:");
input = Console.ReadLine();
if (!int.TryParse(input, out age)){
Console.WriteLine("{0} is not a number!", input);
Console.ReadLine();
return;
}
if (age < 18) {
Console.WriteLine("Sorry, Come back when your older");
Console.ReadLine();
return;
}
|
|
|
|
|
Can I use the technique below to ask a user for their security code as well. Assuming the scurity code is 2090, If the user enter a wrong code...a message comes up.
if (!int.TryParse(input, out code)){
Console.WriteLine("{0} is not a number!", input);
Console.ReadLine();
int code;
string codeInput;
I tried it using the technique above, but I had to press the enter key twice before I got any message from it
|
|
|
|
|
Can I use the technique below to ask a user for their security code as well. Assuming the scurity code is 2090, If the user enter a wrong code...a message comes up.
if (!int.TryParse(input, out code)){
Console.WriteLine("{0} is not a number!", input);
Console.ReadLine();
int code;
string codeInput;
or can I just do it this way int code = 2090;
I tried it using the technique above, but I had to press the enter key twice before I got any message from it
|
|
|
|
|