|
You may get more interest using a less viral license
|
|
|
|
|
Dear all,
I'm stuck once again and calling on you for aid. I want to convert a byte array to an arraylist. I managed to write some code that will put my byte[] data in a file :
Byte[] result = (Byte[])foundRows[0]["bin_file"];
using (BinaryWriter binWriter = new BinaryWriter(File.Open("@C:\test.txt", FileMode.Create)))
{
binWriter.Write(result);
}
This works fine but I would like to write it to an ArrayList so I can process it from there. Reading it back from the file into an ArrayList seems unlogical for me and unneccesary too.
ArrayList list = new ArrayList();
StreamReader se = new StreamReader("@C:\test.txt");
string line = se.ReadLine();
while (line != null)
{
list.Add(line);
line = se.ReadLine();
}
se.Close();
Can somebody point me in the right direction on how to tackle this problem ? With other words, how can I put my byte[] data directly into an ArrayList.
Kind regards,
Rick
|
|
|
|
|
Arraylists are a bit old fasioned these days. You should be using some form of generic list instead.
2 easy ways.
byte[] byteArray = new byte[5];
List<byte> byteList1 = byteArray.ToList();
List<byte> byteList2 = new List<byte>(byteArray);
1) In .net 3.5, there is a ToList() extension method on arrays.
2) One of the constructor for List<> takes an array.
Simon
|
|
|
|
|
You have an array and need to represent it in a ArrayList. Right ? You can use List<T> .
byte[] yourArray = ...;
List<byte> list = new List<byte>(yourArray);
This will insert all the array elements to the list. To get items, you can iterate items on the list.
|
|
|
|
|
I have to convert some Java code to C# and I've stumbled over the Error class. I have been told already that the use of Error instead of Exception allows to bypass catch-clauses for all Exceptions. Now C# doesn't have a direct equivalent to Error, AFAIK. Also at the place of the Error the internal state of the program is corrupted, so abortion makes sense. Am I supposed to use the Exception or even InvalidOperationException then?
|
|
|
|
|
jluber wrote: Am I supposed to use the Exception or even InvalidOperationException then?
It doesnt matter, but a more specific Exception type is preferred. Main thing it to make a clear message so the user can see what went wrong.
|
|
|
|
|
Will do so. Thanks for the clarification!
|
|
|
|
|
Hi,
I have created a c# windows project and in same solution i ve one setup and deployment project also.
what i need is to ask for the serial key before installtion and if the entered key does match with my predefined logic then installation must be aborted.
i ve tried Customer Information dialog in Setup project's User Interface but i want to varify the Serial Key with my own logic and length of the key may vary, that i could not do with it.
Waiting for some helpful reply....
- Dev
|
|
|
|
|
hi guys
i have a dataset named mds in my c# project 2005, there is an datatable named mdt in this dataset and there are four columns in this datatable ,
but after getting data from database when i populate this datatable from dataadapter.fill(mdt) method so values are not there in the table though it shows the number of rows , why is that ?
thanks in advance
hello
|
|
|
|
|
Could you please post the code how you try to achieve this. There might be a slight hickup somewhere along the lines in your code.
Cheers
|
|
|
|
|
I wish to be a Prophet
If i was one, i was going to tell you exacly what is wrong, why dont you post your code and we will tell you what went wrong.
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
Hi,
I don't know if this is the right forum to ask this question about MSMQ and C#.
Sorry, if I have posted this at the incorrect forum.
This is regarding a possible issue which could occur with the use MSMQ 3.0 (Windows XP Professional – SP2) for storing large no of messages.
We are working on storing messages into MSMQ 3.0 through .NET application (Using .NET 3.5). I have read in some articles that there is a disk quota of 8 GB allocated for storing of MSMQ messages and beyond which it can’t store the messages into the queue. The problem could occur if the size of no of messages in MSMQ equals this max limit. So, it is necessary to check this private queue size. With this current queue size it would be possible to check if the max limit has reached or not. So far, we have not found anything which would return us current queue (private) size.
To solve this problem I am working on the following approach.
1. Maintain the size of all queued messages into a text file on file system and update this when required. Also this could be used to check if any further messages could be saved into MSMQ.
2. Check for total size of messages before saving it into MSMQ by reading this info from the text file.
3. Increment it with the size of message, in case this new message was saved to MSMQ.
4. Decrease this file size if the message was removed from MSMQ.
I would like to know if there is any other alternative available for MSMQ max queue size limit. Any solution or suggestion regarding the same will be greatly appreciated.
Thanks & regards,
Vaibhav
|
|
|
|
|
So, you have 8GB in your MSMQ, and that is full?
|
|
|
|
|
leppie, thanks for ur prompt reply. No that is not the case,we r just considering this possibility and this may happen in our case. Basically we need a persistent medium to store the messages and then read them back again for further processing and that's why we r searching for MSMQ.
So, if there is any alternate way for getting current queue size it would be very helpful. Is there any property (Within System.Messaging namespace) which can return total size of messages currently stored in MSMQ? Otherwise we may just have to store size of each message in file before storing it in MSMQ.
Many Thanks for the reply.
|
|
|
|
|
I dont really know much about MSMQ, but I can tell you it is not meant for persistence. Can a database not be used for persistence, or the file system?
|
|
|
|
|
Hello,
im still new to Rad controls, and what i want to do is very simple, loading the combo box with data, from a table. i can fill in the details perfectly from my code, but when i click the combo box its not dropping down. Im filling it at page load.
please note this is radcontrol but populating using c#.
I have also posted this on Tek-tik forumns, its quite urgent and hope to solve it soon.
|
|
|
|
|
So, you've posted this in the right place by posting this on the Telerik forums where Telerik staff prowl like Cheetah's waiting to pounce on any unsuspecting questions and deliver answers with their laser like efficiency. Why do you think you'll get a quicker answer here?
|
|
|
|
|
I still havent got anything from them. I just thought maybe someone might help. I also cant find good material on RAd Controls.
Thanks
|
|
|
|
|
hi all,
I retrieving the fieldname(clientinfo) from the database,datatype is text.this field contains very lenghty string.....when I retrieving the fieldname that time error is occur like following.
System.IndexOutOfRangeException: clientinfo at System.Data.ProviderBase.FieldNameLookup.GetOrdinal(String fieldName)
plz reply me If you know...
Thanks
Rajendran.AL
|
|
|
|
|
You need to provide more information if you want people to help you. Post your code, the full exception message and the error stack.
Simon
|
|
|
|
|
Let us See your Code
Vuyiswa Maseko,
Sorrow is Better than Laughter, it may Sadden your Face, but It sharpens your Understanding
VB.NET/SQL7/2000/2005
http://vuyiswamb.007ihost.com
http://Ecadre.007ihost.com
vuyiswam@tshwane.gov.za
|
|
|
|
|
I have some IP and some file name that exist on this FTP machine.
I want to launch the file in Run Time from this machine.
The file can be exe file or some batch file ...
How can i do it ?
|
|
|
|
|
System.Diagnostics.Process.Start(@"c:\yourfile.exe");
Simon
|
|
|
|
|
But how i make the connection to the FTP Server ?
Can i do the "Start Process" directly to "FTP://SomeIP/SomeFile.exe" ?
I mean - can i write it like this :
System.Diagnostics.Process.Start(@"FTP://SomeIp/SomeFile.exe");
??
|
|
|
|
|
I don't think you'd be able to do that.
You will have to download the file and then run it.
This[^] shows how you can download a file through FTP, if you don't already know.
My current favourite word is: I'm starting to run out of fav. words!
-SK Genius
Game Programming articles start - here[ ^]-
|
|
|
|