|
Depends on what exactly a column is - do you have have an array of rows or an array of columns?
If you have an array of rows, sorting by the first column should be easy:
(warning: untested)
static void SortByColumn<T>(T[][] data, int column) where T : IComparable<T>
{
Array.Sort<T[]>(data, (T[] row0, T[] row1) =>
{
return row0[column].CompareTo(row1[column]);
});
}
Last modified: after originally posted -- angle bracket formatting failure..
|
|
|
|
|
Hey guys,
I need to click pictures using a webcam.... in c#.....
how to do it???
Any reference or link will help a lot...
Waiting for ur reply
Umang Jain
|
|
|
|
|
What? A webcam is an image/video capture device. A mouse is a pointing/clicking/scrolling device. I don't see how you're going to make these interchangeable.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
i want to capture images using a webcamera in c#... whenever the user wants i.e. by clicking a button alongside....
|
|
|
|
|
Here[^] is one. If you search here / google you'll find many others.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
|
Hi everybody.
Just spent some very frustrating houres fighting with Vista.
Wanted to know, what exception I get, when I write to a folder where I hav no rights. OK - just some lines and I'll see:
StreamWriter sw = null;
try
{
sw = new StreamWriter( @"C:\Windows\System32\MyService\test.txt", true, Encoding.GetEncoding( "windows-1252" ) );
sw.WriteLine( "sometext" );
}
catch (Exception e)
{
MessageBox.Show( e, "ERROR", MessageBoxButtons.OK, MessageBoxIcon.Warning );
}
finally
{
if (sw != null) sw.Close();
}
I took C:\Windows\System32\MyService\test.txt because I was to lazy to change the rights of some testpath and I know (knew?) I could not write there as 'normal user'.
The result: no exception and no file???
what the?
check the path - OK
try to write from cmd (copy con: C:\Windows\System32\MyService\test.txt) - Access is denied. 0 file(s) copied.
So I change the rights for Users on C:\Windows\System32\MyService to Full Access.
Rerun of prog gives the same results???
copy con: now works
After some headscratching and wondering I changed the filename in the program to test2.txt. Now it writes the file. Back to test.txt - no exception and no writing???
Took away Full Access (and write and modify and write) and tried test3.txt. As expected no and no. Back to Full Access - test3.txt no and no, test4.txt no problem.
I created a new folder under System32. Same results as before.
If I do the same with a path like C:\testpath, everything works as expected. Normaly I can write, if I take away some rights (deny write or something) I get my exception (UnauthorizedAccessException by the way)
So how does .NET or something first supress an exception and then somehow remember it later?
Please help
Norbert
PS. please forgive any errors in my english
|
|
|
|
|
Typical Vista crappyness.. did you check whether the file was wrongly and silently redirected to some obscure place?
|
|
|
|
|
I tried, but didn't find it. Any idea where to look? And to prevent it from happening?
|
|
|
|
|
"logical" locations would include My Documents, the application's data folder, and NUL (nowhere, just silently discarded)
It might be more reliable (at least exception-wise) to create and write the file in a temporary place and then move or copy it to System32 (File.Move or File.Copy )
Then again, this is Vista. All bets are off. It has a habit of ignoring bad things silently but complaining loudly about not-so-bad things..
|
|
|
|
|
Nope. Can't find anything. I think I have to check after the first write, that there is something there.
Stupid.
But thanks anyhow.
|
|
|
|
|
At the catch clause in order to show the error message use:
System.Diagnostics.Trace.Assert(false,"Error:" + err.ToString());
OR if running a debug version:
System.Diagnostics.Debug.Assert(false,"Error:" + err.ToString());
Do not attempt to show a message box window when running a service. Your exception line throws an exception.
When writing files especially in vista, you should use Environment.SpecialFolder and not a hard coded path:
string dirPath = Environment.GetFolderPath(
Environment.SpecialFolder.LocalApplicationData);
Natza Mitzi
|
|
|
|
|
Hi
I am able to make both the client and the server to communicate ..
The message from the server is displayed in a listbox control..
I have displayed an acknowledgement message from the server say,"Welcome to the server "in the listbox.
I have also added a label box in a table control
If the received message is "welcome to the server" the color of the label should change...The following code does not give me any error but the color of the label is not changed.Can you spot out the mistake
data = new byte[1024];
int recv = sock.ReceiveFrom(data, ref tmpRemote);
listBox3.Items.Add(Encoding.ASCII.GetString(data, 0, recv));
String gt = data.ToString();
if (gt=="Welcome to the Server")
{
lb9.BackColor = Color.Green;
}
|
|
|
|
|
Hi,
what you need is called "debugging", which includes looking at intermediate values, and possibly rethinking your code.
Did you ever look at the value of gt?
Why is it you use Encoding.ASCII.GetString() to display something, however you use ToString() to compare it to a known value?
This is one occasion where less code will give you a better outcome.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:11 AM
|
|
|
|
|
Hi
I have modified the code...Still the color does not change
String fr = Encoding.ASCII.GetString(data);
if (fr.Equals( "Welcome to the Server"))
{
lb9.BackColor = Color.Green;
}
|
|
|
|
|
Hi,
is the statement lb9.BackColor = Color.Green; being executed at all? check either by single-stepping or by adding some observation statement (Console.WriteLine("green")) inside the code block.
If it is and it does not show, here are several possible reasons:
- your code is not running on the main thread (then lb9 needs InvokeReqruied/Invoke)
- your code is followed by something that takes long or forever, and sits in an event handler (such as a button click); the GUI effects will show only when its done unless you insert an Applications.DoEvents() which is just a hack, not a recommendation.
- your code is followed by something that changes the color back before the GUI had an opportunity to show the changes.
Learn to debug: add observational code (logging, tracing, MessageBox, Console.WriteLine, whatever) and/or single-step.
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:12 AM
|
|
|
|
|
mrithula8 wrote: String fr
Just changing your variable name rarely affects the outcome of your code. Just as naming your dog one name vs another the dog is still the same dog.
The best way to accelerate a Macintosh is at 9.8m/sec² - Marcus Dolengo
|
|
|
|
|
Expert Coming wrote: Just changing your variable name rarely affects the outcome of your code. Just as naming your dog one name vs another the dog is still the same dog.
I'm going to have to remember that!
|
|
|
|
|
Hi,
just reread your post and now noticed text and code don't match, have a look at the casing of "Welcome" and "Server". You may want to perform a case-insensitive compare, e.g. by using string.Compare(... , ... , true)
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Saturday, March 7, 2009 4:08 PM
modified on Sunday, June 12, 2011 9:12 AM
|
|
|
|
|
Hi
The message "Welcome to the Server" is sent by the server and is displayed in the listbox.The color of the label changes with a click of the item "Welcome to the Server" in the listbox.But my requirement is that the color of the label should change when the message "Welcome to the Server" is sent from the server and is displayed in the listbox control and not with a click of the listbox item...Is that possible?Can you please tell me how i can go about this?
private void listBox3_Click(object o, EventArgs e)
{
Object df = listBox3.SelectedItem;
String kl = (String)df;
if (kl == "Welcome to the Server")
{
lb9.Text = "Active";
lb9.BackColor = Color.Green;
}
else
{
lb9.Text = "Inactive";
lb9.BackColor = Color.Red;
}
}
|
|
|
|
|
Hi,
1.
AFAIK there is no ListBox event firing when something gets added to its Items, so you will have to modify the code that adds stuff to the ListBox.Items, which probably resides in an event-driven handler anyway (some kind of DataReceived handler I would hope).
2.
The code shown is wrong and ugly for several reasons:
- ListBox.SelectedItem can be null (when nothing is selected), in which case you are switching to Inactive;
- once the server is active, it probably will add more stuff to the ListBox, and everytime that a some new line is clicked, assuming it is different from "Welcome to the Server" it will again declare an inactive state. Remedy: check on the presence of something that signifies end of session.
- what happens if the "Welcome to the Server" message changes for some reason, say extra spaces, carriage returns, etc? Checking for an exact match isn't probably not very wise, I would at least doif (kl.ToLower().Contains("welcome to the server"))...
Luc Pattyn [Forum Guidelines] [My Articles]
- before you ask a question here, search CodeProject, then Google
- the quality and detail of your question reflects on the effectiveness of the help you are likely to get
- use the code block button (PRE tags) to preserve formatting when showing multi-line code snippets
modified on Sunday, June 12, 2011 9:12 AM
|
|
|
|
|
I have an application that queries records from a Visual FoxPro 8.0 table. I created an install project for this application an included the Vfpoledb merge module. When running the installed application on the development computer everything works fine. But when I install it on a Vista computer and try running it comes back with the error 'Cannot register Vfpoledb.1'. I'm installing it under the admin account. Any ideas on how to fix this problem? Thanks.
|
|
|
|
|
hi,
i wanna ask for how to make the .exe file run automatic after finish copy it from a location to another location. the exe file will run automatic without double click on it..
thanks..
- tyrone
|
|
|
|
|
If you mean the exe that is your application then you can't.
If you're moving an exe file within your application, then you can use the System.Diagnostics.Process class and it's Start method to start the exe.
DaveBTW, in software, hope and pray is not a viable strategy. (Luc Pattyn)Visual Basic is not used by normal people so we're not covering it here. (Uncyclopedia)
|
|
|
|
|
Your can use your code to start it:
System.Diagnostics.Process.Start(anotherlocation+filename);
|
|
|
|