|
rizvi_codeproject wrote: url for reference..
Oh, you should have said that right away.
Here: http://www.google.com/[^]
Kristian Sixhoej
"You can always become better." - Tiger Woods
[ My blog ]
|
|
|
|
|
hi,i'm trying to get the details of each process in c# but some of its attributes didnt return anything, (i made object of class Process --> p):
1) p.ExitTime;
the ERROR: process was not started by this object
2) p.startInfo.WorkingDirectory;
but it didnt return the directory of the process,just a empty string
3) p.username;
empty string, i searched the net and tried many codes but nothing helped me ,they all return the usename of the computer, i want something like task manager's username:system, local service ....
And one more thing :how does taskmanager calculate cpu usage?
|
|
|
|
|
Hi,
the MSDN documentation on the Process class includes this paragraph, it may be relevant to you:
"The process component obtains information about a group of properties all at once. After the Process component has obtained information about one member of any group, it will cache the values for the other properties in that group and not obtain new information about the other members of the group until you call the Refresh method. Therefore, a property value is not guaranteed to be any newer than the last call to the Refresh method. The group breakdowns are operating-system dependent."
shefa' isied wrote: how does taskmanager calculate cpu usage?
the Microsoft guy who wrote Task Manager is good friends with the Microsoft guy who wrote the scheduler, so he is allowed a peek in some system tables we mortals are not supposed to access.
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:01 AM
|
|
|
|
|
Hi
I would like to drag my contact(in icon view) to any location point by mouse. The behavior is same as icon view, without auto arrange and without align to grid in window explorer. I found all drag and drop example use index to represent location and the drop is to nearest location(by index).
Anyone know how to implement it?
Thanks first.
Regards,
PeiYang
|
|
|
|
|
As no-one has answered your question, I'll have a go.
Take a look at Control.MousePosition and see if that helps you.
Good Luck.
Henry Minute
Do not read medical books! You could die of a misprint. - Mark Twain
Girl: (staring) "Why do you need an icy cucumber?"
“I want to report a fraud. The government is lying to us all.”
|
|
|
|
|
Thanks. I already have a look on Control.MousePosition.
I can get the mouse position but i can't drop it at the specific location.
All example that i found is:
1. Get the drag item detail and index when drag.
2. Get the mouse position when drop.
3. Base on mouse position, the application convert the mouse position to index. Every index represent a rectangle. Any point in the rectangle will use same index.
4. The item will insert at the rectangle represent by the index.
The function that i found all will draw or insert picture base on index and not actual mouse position. It need to pass in index and not mouse position. So, anyone have any suggestion?
Regards,
Pei Yang
|
|
|
|
|
Hello!
I'm trying to have a custom-sorter class to sort my objects.
I want my objects to always be in a certain order(not alphabetically).
In my Compare(object a, object b) method I check which objects they are and return 1 or -1 depending on which one I want to come first. How exactly does it work, do I return -1 if I want object a before object b in my collection? It doesn´t seem consistent to me, some values get sorted correctly and some don´t.
|
|
|
|
|
You probably should post your code and your test data.
If the Lord God Almighty had consulted me before embarking upon the Creation, I would have recommended something simpler.
-- Alfonso the Wise, 13th Century King of Castile.
This is going on my arrogant assumptions. You may have a superb reason why I'm completely wrong.
-- Iain Clarke
[My articles]
|
|
|
|
|
-1 if a less than b,
0 if a equal b,
1 if a greater than b.
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 wrote you a little sameple which might help.
I have 3 types of pet:
public class Dog { }
public class Cat { }
public class Rabbit { }
I dont want to order these alphabetically, I want to order them in order of my preference of them as pets. I like cats more than dogs, and dogs more than rabbits. I could write a comparer to always order a list of pets in my prefered order:
public class MyPetPreferenceComparer : IComparer
{
#region IComparer Members
public int Compare(object x, object y)
{
if (x.GetType() == y.GetType())
return 0;
if (x is Cat)
{
return -1;
}
if(x is Dog)
{
if (y is Rabbit)
return -1;
return 1;
}
if (x is Rabbit)
return 1;
return 0;
}
#endregion
}
Now the test code:
ArrayList list = new ArrayList();
list.Add(new Rabbit());
list.Add(new Cat());
list.Add(new Dog());
list.Add(new Cat());
list.Add(new Rabbit());
list.Add(new Dog());
list.Sort(new MyPetPreferenceComparer());
foreach (object obj in list)
{
Console.WriteLine(obj.GetType().Name);
}
Outputs:
Cat
Cat
Dog
Dog
Rabbit
Rabbit
One thing Id add - nowdays we tend to prefer the generic versions of these sorts of interface so try to use IComparer<T> in System.Collection.Generics
|
|
|
|
|
|
Hi,
an int comparer could just return the difference, as in:
public static int Compare(int a, int b) {return a-b;}
BTW: you MUST return zero when both objects are identical.
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:02 AM
|
|
|
|
|
Hi All,,,
I Get A Data From a sql server2005 Veiw/table using Dataset And Data Adapter,,,
I Want A C# Code To Return All constraints and Foreign Key At This Veiw/table.
please help me about this code
thanks all;
|
|
|
|
|
Do not repost the same vague question.
|
|
|
|
|
using System;
public class class1
{
static void Main(string[]args)
{
try
{
string s1 = args[0];
string s2 = args[1];
int i1 = int.Parse(s1);
int i2 = int.Parse(s2);
int i3 = i1 + i2;
Console.WriteLine(i3);
}
catch (Indexoutofrange Exception)
{
Console.WriteLine(Exception.message);
}
Console.WriteLine("hello");
}
}
when iam running this program it is showing the following errors
1.the tpe or namespace name could not be found
2.system.exception does not contain a definition for message
|
|
|
|
|
C# is case sensitive.
replace following lines:
catch (IndexOutOfRangeException exception)
{
Console.WriteLine(exception.message);
}
Console.WriteLine("hello");
}
}
Calin
|
|
|
|
|
aratireddy wrote: 1.the tpe or namespace name could not be found
There is no class called Indexoutofrange . It should be IndexOutOfRangeException
aratireddy wrote: system.exception does not contain a definition for message
aratireddy wrote: catch (Indexoutofrange Exception)
Exception is a class name and you can't use it as a variable. Try
catch (IndexOutOfRangeException ex)
{
Console.WriteLine(ex.message);
}
|
|
|
|
|
You asked this same question 4 hours agao and got an answer. Why repost it?
|
|
|
|
|
my video file extension is wmv.and i want that water mark for the entire duration of time
|
|
|
|
|
It would be easier if you posted answers in their original thread, instead of starting a new post. The forum will be harder to read if the same questions are being repeated over and over again.
So, replies go here[^].
BTW, we're no take-away chinese, and ordering code usually doesn't work. Most of us are glad to help a collegue out, but the chances that someone is going to write the code for you are very slim.
I are troll
|
|
|
|
|
Hello,
i use this to get all files in directories :
<br />
string[] files = Directory.GetFileSystemEntries(@"C:\");<br />
int filecount = files.GetUpperBound(0) + 1;<br />
if (filecount != 0)<br />
{<br />
DirectoryInfo di = new DirectoryInfo(@"C:\");<br />
<br />
foreach (FileInfo file in di.GetFiles())<br />
{<br />
DateTime Now = DateTime.Now;<br />
string name = file.Name;
string fullName = file.FullName;
}<br />
i would get not all files, but a file with a specific name lake doc1.pdf, thank you verry mutch.
|
|
|
|
|
just test if (file.Name.Equals("doc1.pdf")) // replace 'doc1.pdf' with your variable
|
|
|
|
|
We can't get the file path directly?? beacause i need to got two file with the same name, for exemple get the files doc1.pdf and doc3.pdf, thank you verry mutch.
|
|
|
|
|
Hi,
Before anyone can give you an answer you do need to decide what your question actually is. You started by asking how to find one file and now that you have that answer you have changed the question.
In the code you posted you used the DirectoryInfo.GetFiles method. If you were to invest some time in reading the documentation for that method and it's overloads you would be able to answer either of your questions on your own.
Alan
|
|
|
|
|
Hi,
as usual it helps to read the documentation: there is an overload of GetFileSystemEntries that accepts a filter, where you can specify part of the filename, as if you were searching in Windows Explorer.
Hence try Directory.GetFileSystemEntries(@"C:\", "doc*.pdf")
BTW: files.GetUpperBound(0) + 1 is terrible, just use files.Length
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:02 AM
|
|
|
|