|
I used the ArrayLists and it worked. However, I used your logic for another form on the application and was successful. Thanks again for your help and patience Radgar.
|
|
|
|
|
Glad to hear that.
Radgar
"Imagination is more important than knowledge." - Albert Einstein
|
|
|
|
|
I am new to progamming world and just want to start with C#.
How can I write a simple program like
The program will ask u
what is your name?
You type:
Robert
and it say
Hi, Robert.
Thank so much.
|
|
|
|
|
The Console class has what you are looking for. Look for the ReadLine() and the WriteLine() methods.
Regards
Senthil
My Blog
|
|
|
|
|
Anonymous wrote:
The program will ask u
what is your name?
Console.WriteLine("what is your name?");
Anonymous wrote:
and it say
Hi, .....
Console.WriteLine("Hi, " + Console.ReadLine());
|
|
|
|
|
I want to save a great float type data array into a SQL server database. But I donot know how to convert a float array (float[]) to a byte array (byte[]) . Please help if anyone can solve this problem, thanks .
xu guoqing
|
|
|
|
|
The BitConverter class does the job. You can do somthing like
<br />
byte[] GetByteArray(float []f)<br />
{<br />
byte[] byteArray = new byte[f.Length * 4];
int index = 0;<br />
foreach(float floatVal in f)<br />
{<br />
byte []convertedBytes = BitConverter.GetBytes(f);<br />
byteArray[index++] = convertedBytes[0];<br />
byteArray[index++] = convertedBytes[1];<br />
byteArray[index++] = convertedBytes[2];<br />
byteArray[index++] = convertedBytes[3];<br />
}<br />
<br />
return byteArray;<br />
}<br />
Does this help?
Regards
Senthil
My Blog
|
|
|
|
|
How can get the codeDOM tree of a method at runtime? Something like this:
((CodeMemberMethod)RetrieveCode(someObject.GetType().GetMethod("MyMethod"))).Statements;
Greetings Harald
|
|
|
|
|
What you are trying to do is logically not possible, unless there is some intermediate file that maps IL to language statements. You see, once you compile the code, the source is gone, it may not even exist on the machine the code is being run. Even if it does, there is no association (except for map files) between the IL and the source.
Regards
Senthil
My Blog
|
|
|
|
|
Your Wrote :
see, once you compile the code, the source is gone,
Where ? Can you explain it little bit more ?
Sreejith Nair
[ My Articles ]
|
|
|
|
|
What the (@^^% do you mean 'where'? No-where! It's forgotten about! Once the source IL is compiled, it isn't needed anymore, so it gets dropped.
What do you think happens when you call .Clear() on a TextBox? Where does that data go?
RageInTheMachine9532
"...a pungent, ghastly, stinky piece of cheese!" -- The Roaming Gnome
|
|
|
|
|
You wrote:
(@^^%
I love to answer for this. but if i do , then what is the difference.
Sreejith Nair
[ My Articles ]
|
|
|
|
|
There is at least a very pedestrian method: I can, probably, access the source code and create the code DOM tree out of it and so on. My question is: Is there a more elgant way, possibly without the need to deliver some textual things.
Harald
|
|
|
|
|
Oh, you're planning to ship your source too?
Regards
Senthil
My Blog
|
|
|
|
|
Right then, how do i encrypt something so that when you click on it instead of windows going 'im an idiot what do i open it with?' (or something like that), do i get it to display a message box, saying something like, 'Stay away from my stuff'.?
Or is this just asking to much?
Any help would be much apreciated. Thanks
|
|
|
|
|
|
People could change thefile association but, smart thinking there, hmm, how do i get the file exension to be associated with the app, without having to do it myself (right-click, open with, etc.)?
|
|
|
|
|
You can add a few keys to the registry:
Under HKCR add a key with the name of your extension, for example ".mef" (my encrypted file).
Add a subkey "Shell", a sub-subkey "Open" and a sub-sub-subkey "Command".
Set the standard value of the new "Command" key to the program you want to execute, for example "notepad %1".
So now you should have:
HKCR
+--.mef
+--Shell
+--Open
+--Command (Standard) "notepad %1"
Explorer will show the icon of the application (notepad in our example) and open notepad when you doubleclick a .mef file.
mav
|
|
|
|
|
I have a program I am writing for my own personl use that takes an XML file and interprets it into a treeview, then if a secion is clicked it shows the information between the tags in a textbox. The problem im having is with this peice of code.
XmlTextReader document = initializeXmlReader();
while((document.Name != e.Node.Tag.ToString()) && (document.GetAttribute("Name")!= e.Node.Text))
{
document.Read();
}
All the tree nodes are made up of the elemets attributes, this code works partially to go through the document and find if the right attribute, but sometimes it returns null, and does not display the next catagory's text.
Here is some sample XML.
<?xml version="1.0" encoding="utf-8" ?>
<Main Name="Desktop Sidebar Help">
<![CDATA[ TEST TEST TEST ]]>
<Key_Cat Name="Overview">
<Sub_Topic Name="Context Menu">TestTestTest</Sub_Topic>
<Sub_Topic Name="Options"></Sub_Topic>
</Key_Cat>
<Key_Cat Name="Basic Panels">
<Sub_Cat Name="Communication">
<Key_Topic Name="Mail Checker Panel">
</Key_Topic>
<Key_Topic Name="Messenger Panel">
</Key_Topic>
<Key_Topic Name="Miranda IM">
</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Groups Panels">
<Key_Topic Name="Stack Group">
</Key_Topic>
<Key_Topic Name="Tile Group">
</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="News"></Sub_Cat>
<Sub_Cat Name="Outlook Panels"></Sub_Cat>
<Sub_Cat Name="System"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="3rd Party Panels">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Skin Development">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Plugin Development">
<Sub_Cat Name="DS SDK Documentation Forum - About"></Sub_Cat>
<Sub_Cat Name="Creating/Adding a Panel">
<Key_Topic Name="Creating an Empty Panel"></Key_Topic>
<Key_Topic Name="Adding Your Panel to Desktop Sidebar">trdtfgrgbergbergbergber</Key_Topic>
</Sub_Cat>
<Sub_Cat Name="Creating a Panel Installation File "></Sub_Cat>
<Sub_Cat Name="Publishing Your Panel"></Sub_Cat>
<Sub_Cat Name="Using Components"></Sub_Cat>
<Sub_Cat Name="Reference"></Sub_Cat>
<Sub_Cat Name="FAQ"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="FAQ">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="Universal Help Engine">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
</Key_Cat>
<Key_Cat Name="About Universal Help Engine">
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media"></Sub_Cat>
<Sub_Cat Name="Media">TESTTESTTEST</Sub_Cat>
</Key_Cat>
<Location ID="http://"><Location>
</Main>
I've been testing it by just clicking the first few treenodes that have a different attribute. But most of the time only one or two will work before it is just stays on the same thing for anything else I click. This is really bothering me. I edited out the text that was inbetween the tags, for length problems in this posting.
Sample of what its doing.
Tree
Desktop Sidebar
--OverView
---Context
---Options
--BasicPanels
---Communication
----Mail Checker Panel
----Messanger Panel
----Miranda IM
and so on
When I click mail checker panel for instance, it will show up right. But then if I click messanger Panel, it will show up with Main Check Panels text instead of Messanger Panels Text, upon debugging I noticed that getattribute is returnning null sometimes, I beleive this is the problem. The text between the tags will, contain HTML which is parsed by the textbox/web browser i've incorpertaited.
Any help would be much apperiated. Also if more code is needed I can post it.
|
|
|
|
|
|
Fixed, first time using this bb software, more accustomed to vb, ivb, phpbb, and ubb....lol
|
|
|
|
|
Hello everyone,
I have a problem with Encrypting and Decrypting files. I read an article about it at the Microsoft-Homepage but this example works only with text files and I want to encrypt and decrypt every file type.
http://support.microsoft.com/default.aspx?scid=kb;EN-US;307010[^].
Maybe the problem is Encoding.
Please help me!
|
|
|
|
|
Actually, the encrypt function will work with any file type, but the decrypt function might not. StreamReader and StreamWriter are to help with reading/writing text from/to streams, so you don't want to use them in this case.
The example code there isn't very efficient for large files either, since it reads in the whole file at once, and your memory will be stuffed.
Here's a more practical version of the last section of the EncryptFile function:
<br />
byte[] buffer = new byte[1024];<br />
int len;<br />
<br />
while((len = fsInput.Read(buffer, 0, buffer.Length)) != 0)<br />
{<br />
cryptostream.Write(buffer, 0, len);<br />
}<br />
cryptostream.Close();<br />
fsInput.Close();<br />
fsEncrypted.Close();<br />
And here's the last 5 lines of the DecryptFile function, works for any file type and file size:
<br />
byte[] buffer = new byte[1024];<br />
int len;<br />
FileStream fsDecrypted = new FileStream(sOutputFilename, FileMode.Create);<br />
while((len = cryptostreamDecr.Read(buffer, 0, buffer.Length)) != 0)<br />
{<br />
fsDecrypted.Write(buffer, 0, len);<br />
}<br />
|
|
|
|
|
|