|
C# would be the better way to go. I was brought up with C++, went over to C# since I also worked with Java and there are similarities. When C++/CLI came about, I was too hooked on C#. Compare the number of posts in the C# forum here versus the C++/CLI forum...
"The clue train passed his station without stopping." - John Simmons / outlaw programmer
"Real programmers just throw a bunch of 1s and 0s at the computer to see what sticks" - Pete O'Hanlon
|
|
|
|
|
Hi,
In my opinion you should try to stay away from c++/cli.
Either choose c++ or C# or like i do: Use C# for gui and stay with c++ for internal processing.
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
Yes, the WPF attacked me, I want to use it to the GUI. thanks for your advice
|
|
|
|
|
hello..
I have one form with datagrid on it. when i click the button on that form, it shows another form on which i made updating database using SQLCommand. When I turn to the first form, the datagrid isn't updated...It is updated only when I close application and start it again- then i see the changes..
I also have this line of code after I close the second form: DataGrid.Refresh()
What should I do?
|
|
|
|
|
Is it ok that i do this after i close the second form:
dataSet.Clear();
dataAdapter.Fill(dataSet);
then, it will work. But, is it ok this, because in the Load method on first form I already set dataSet and fill adapter? or it isn't matter at all?
|
|
|
|
|
hi all does anyone know how to convert the following js into c# ?
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which is contained in the following loop (for clarity):
for(var c:Number = 0; c < src.length; c ++){
if(cc>=i) {
cc = 0;
}
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
cc++;
}
I've searched and found the equivalent for both but dont seem to be able to put it together, it should be something like this in c#:
my_str += new String(new char[]{(Int32)Data[c] ^ keys[cc]});
but that obviously fails and im just confusing myself now. any pointer very very much appreciated.
keys is already converted into an array of ASCII codes and Data is a string at present, i was thinking I should convert it into an array of ASCII codes as well.....
thank you
tim
|
|
|
|
|
ignore
was having one of those moments when you cant see the woods for the trees (or whatever!)
my_str += (char)(letters[c] ^ keys[cc]);
does the job after creating the letters array using (Int32)input[i] in a for loop
thanks
anyway.
t
|
|
|
|
|
You are on the right track, you just need a few more parentheses so that you are casting just the character instead the entire result.
Don't use += to build the string, put all the characters in an array and create a string from that.
char[] chars = new char[Data.Length];
for (int c = 0; c < Data.Length; c++) {
chars[c] = (char)(((int)Data[c]) ^ keys[cc++ % i]);
}
string my_str = new string(chars);
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi guffa
whats the difference between creating an array(then string) or building the string as we go. I dont mean that in a rude way I'm intrigued as they produce two different results from what *should* be the same string or is it the char creation that differs the result ?
tim
|
|
|
|
|
The difference is that if you use += to create the string, you are creating every intermediate string as a separate object.
If your code creates the string "This is a test", it will also have created the strings "T", "Th", "Thi", "This", "This ", "This i", "This is", "This is ", "This is a", "This is a ", "This is a t", "This is a te" and "This is a tes".
Strings in .NET are immutable. When you use the += operator, you are actually creating a new string object every time, copying the data from the original string.
For very short strings, this is not a big problem, but it quickly gets bad. To create a 100 character string, you will have created 10 kB of strings. To create a 1000 character string, you will have created 1 MB of strings.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi
thanks for that, thats very interesting and something I didn't realise.
but... strangely enough that must be the way that javascript handles it (i think *gulp*) as the original way I was doing it :
c#
my_str += (char)(letters[c] ^ keys[cc]);
produces exactly the same result as:
js
my_str += String.fromCharCode((src.charCodeAt(c) ^ keys[cc]));
which was(after to base64 encoding for transport(the unencoded isn't really printable)):
OhFBBxQWEBFLGgsEHgoVRBwSEAYCCw==
and yours produced:
OhhBBh4eCRNPEQkMBQQVVRgaHggBBQ==
I was doing this as an little encryption thing between flash and .net as i couldn't find anything that was compatible, I tried many different ones (rijndael, TEA etc) but all the flash conversions of them produced completely different results from the c# end and I was tearing my hair out trying to do my own conversions of them so I thought i would write a simple (obviously not that strong - but it doesnt need to be super difficult) bit of encryption that i could rewrite in javascript(for the .as files in flash and also for php etc) that would suffice.
but... like you say the larger the string then the larger the problem(or at least load) so now i'm wondering if theres a way to reproduce what you've said in js - this isn't a problem for what I'm doing now but it would be nice to have a better model in place for future.
something for me over the weekend
thanks for your replies and if you have any thoughts I'd be really interested to hear them.
tim
<edit>
i suppose in js i would just create an array and then use push to add them in and then create the string...but i still don't get why it produces different results from what *should* be the same string...hmmmm time for some script outputting...
modified on Friday, July 4, 2008 8:33 PM
|
|
|
|
|
How did you turn the string into a byte array, so that it could be base64 encoded?
I think that the problem is that the codes are using different character sets. The characters outside the ASCII set uses different character codes in different character sets.
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi
in c# i used
Convert.ToBase64String(Encoding.ASCII.GetBytes(my_str))
and in js i used the base64 encoding i found in amongst the encryption files from http://labs.boulevart.be/index.php/2007/05/23/encryption-in-as2-and-as3/[^] which is where my problems began.... not that i'm putting down what they have there, I just couldn't get it to produce the same results from my end with the rijndael/TEa encryption, the base64 seems to be fine
tim
edit:
this is the function that encodes to base64 in js:
*/
private static var base64chars:String = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=";
public static function encode(src:String):String {
var i:Number = 0;
var output:String = new String("");
var chr1:Number, chr2:Number, chr3:Number;
var enc1:Number, enc2:Number, enc3:Number, enc4:Number;
while (i < src.length) {
chr1 = src.charCodeAt(i++);
chr2 = src.charCodeAt(i++);
chr3 = src.charCodeAt(i++);
enc1 = chr1 >> 2;
enc2 = ((chr1 & 3) << 4) | (chr2 >> 4);
enc3 = ((chr2 & 15) << 2) | (chr3 >> 6);
enc4 = chr3 & 63;
if(isNaN(chr2)) enc3 = enc4 = 64;
else if(isNaN(chr3)) enc4 = 64;
output += base64chars.charAt(enc1)+base64chars.charAt(enc2);
output += base64chars.charAt(enc3)+base64chars.charAt(enc4)
}
return output;
}
|
|
|
|
|
tim_gunning wrote: in c# i used
Convert.ToBase64String(Encoding.ASCII.GetBytes(my_str))
The ASCII encoding only handles characters with character code 0 to 127. To get the equivalent of the JScript code you would have to loop through the string and get the character codes into a byte array, so that you get the characters with character codes from 0 to 255.
The JScript code claims to encode a string to base64, but that it not really possible. It assumes that there are never any character codes above 255. If there is, the result will be incorrect.
To correctly turn a string into base64, you first have to encode it using an encoding that can handle the full unicode character set, like UTF-8:
Convert.ToBase64String(Encoding.UTF8.GetBytes(my_str))
Despite everything, the person most likely to be fooling you next is yourself.
|
|
|
|
|
hi
originally I wss using UTF8 but the js wasnt coping and then I realised chars were missing from the c# end (anything over 127 or so) which I needed (long story....;p) anyway to cut it short I've encoded the js to UTF8 and the c# and then both to base64, used StringBuilder to create my return string and both the js in the flash and c# are producing identical results which is what I needed, I'll post it up here at some point as it may be of interest to someone.
thanks for all your help/pointers guffa, very much appreciated.
tim
|
|
|
|
|
Guffa wrote: To create a 100 character string, you will have created 10 kB of strings. To create a 1000 character string, you will have created 1 MB of strings.
Great ! I am curious to know how you calculated this ?
|
|
|
|
|
You just add the length of the strings, and multiply by two (as each character is two bytes).
(1+2+3+4+...+98+98+99+100) * 2 = (101 * 50) * 2 = 10100
(1+2+3+4+...+998+999+1000) * 2 = (1001 * 500) * 2 = 1001000
The actual amount of memory used is slightly more, as there is some overhead in each object.
Despite everything, the person most likely to be fooling you next is yourself.
modified on Sunday, July 6, 2008 9:25 AM
|
|
|
|
|
Thanks.
|
|
|
|
|
Hi,
I have created a windows service which looks at an xml file to get data.
The xml file gets modified using a windows application.
If the xml file is changed then the service has to be uninstalled and then installed again so that the service picks up the new xml file data, otherwise the service looks at the old xml data.
Question:
How can I avoid the manual interaction with the visual studios command where at present I use it to uninstall and install the service? Can I make the windows application to do the un/install everytime there is a change in the xml file?
Thanks
|
|
|
|
|
Iy shouldn't be nessecary to reinstall every time the xml changes.
You could add a FileSystemWatcher to monitor changes in the xml-file and make the service load the updated xml-file.
|
|
|
|
|
Your design is wrong. You have to use a FileSystemWatcher , handle it's event and load the XML file when it changes.
|
|
|
|
|
I'm building a Windows Installer project using Visual Studio. I've got it set where the app data is installed in the AllUsers folder if the users clicks the "Everyone" radiobutton.
My problem is that when I switch to a non-administrative account, I can start the app but as soon as the program tries to access the AllUsers folder, an "Access denied" exception is thrown! What am I doing wrong?
I've read articles that say your app will be vista compatible if an non-administrative user can access it in XP. (which is what I'm using)
Happy 4th!
Richard
"Make it as simple as possible, but no simpler" Issac Newton
|
|
|
|
|
In the Windows security model, a non-administrative user is not (or at least should not) be able do anything affecting other users.
You can only read from the AllUsers folder. All settings should be stored in a per-user folder, not in your program's installation folder.
|
|
|
|
|
Thanks for the reply. That does shed some light into my problem. However, I am still confused. One of the program features involves writing to a central log when a record is viewed. This log needs to visible for all users. What directory is safe for all types of users?
"Make it as simple as possible, but no simpler" Issac Newton
|
|
|
|
|
Can anybody share some knowldge on how to detect un used regisrty key from a system nd deleting those unused keys.
regards,
|
|
|
|