|
|
That indicates the process terminated with an error. The fastest way (IMHO) to determine what caused the problem is to:
- Debug your app and see what arguments you're passing the
.exe
- Run the
.exe manually (in a command window) using those arguments and inspect the output /ravi
|
|
|
|
|
You, sir, should be nominated for sainthood or something.
Nicely done.
Why is common sense not common?
Never argue with an idiot. They will drag you down to their level where they are an expert.
Sometimes it takes a lot of work to be lazy
Individuality is fine, as long as we do it together - F. Burns
|
|
|
|
|
Thanks, Wes! Just trying to live up to the CPian code - bad puns intended.
/ravi
|
|
|
|
|
sir please tell me is this line which i am passing in filename of psi is correct or not?
psi.FileName = @"C:\Program Files\MySQL\MySQL Server 5.0\bin\mysqlimport.exe";
|
|
|
|
|
Assuming that's where MySql is installed, probably yes. Did you try running the command manually?
/ravi
|
|
|
|
|
yes sir that is stored there ....ok i will run actualy there is problem in system as soon as it will be functioning well
|
|
|
|
|
|
sir but in this link the database is sql server and i am using mysql database ....
|
|
|
|
|
I need to develop a toy tracking system using RFID. i need to know how to code an RFID using C#. I also need to knwo which RFID should i purchase and one that is easily available. I was wondering if someone could help with a step by step procedure of how to do it! Please Please please!!!
|
|
|
|
|
See here[^]; it always helps if you do some research first, and then come back here with specific questions.
Unrequited desire is character building. OriginalGriff
I'm sitting here giving you a standing ovation - Len Goodman
|
|
|
|
|
Hi,
I am trying to get a date in the format dd/MM/yyyy HH:mm:ss from a datetime.addseconds operation but everything that is returned (unless I tickcount - which tells me the elapsed time) is wrong, i.e. 1601,1,1,0,0,0.
While I 'understand' why I get that response I don't know how to fix it.
Code:
long st = procs.StartTime.ToFileTime();
DateTime stDt = new DateTime(1601, 1, 1, 0, 0, 0).AddSeconds(st);
If I do this
string stime = String.Empty;
stime += (Environment.TickCount / 86400000).ToString() + "d";
stime += (Environment.TickCount / 3600000 % 24) + "h";
stime += (Environment.TickCount / 120000 % 60) + "m";
stime += (Environment.TickCount / 1000 % 60) + "s";
I get 7d10h17m44s.
How do I get the difference between datetime.now and that process startdate expressed in the desired format or how do I convert 7d10h17m44s into a usable format so that I can deduct it from datetime.now?
Thanks for your time.
|
|
|
|
|
CCodeNewbie wrote: how do I convert 7d10h17m44s into a usable format so that I can deduct it from datetime.now?
DateTime result = DateTime.Now - new TimeSpan (7, 10, 17, 44); /ravi
|
|
|
|
|
1.
I fail to understand how your code matches your problem description. What has ToFileTime to do with it?
2.
DateTime is the fundamental CLR type dealing with dates and times, and it holds most everything you'll ever need. What you should do is:
- convert your dates and times to DateTime values (if they start out differently);
- then operate on those DateTimes;
- and finally convert them to something else, if that is what you need.
So DON'T start with ToFileTime(), if at all you should do that at the end and only then.
3.
Your second snippet is very bad; it is calling Environment.TickCount four times, and each of them may well return a different value!
4.
How about this:
DateTime dt1=DateTime.Now;
DateTime dt2=dt1.AddSeconds(10000);
TimeSpan span=dt2-dt1;
string text1=span.Days+"d "+span.Hours+"h "+span.Minutes+"m "+span.Seconds+"s";
string text2=span.ToString();
And obviously you should consider creating a little static method that turns a TimeSpan in the exact format you want everywhere.
|
|
|
|
|
Hi Luc,
Thanks for your reply but I just can't seem to find the error.
long dt1 = DateTime.Now.Ticks;
long dt2 = procs.StartTime.Ticks;
long dt3 = new DateTime(1601, 1, 1, 0, 0, 0).AddTicks(dt2).Ticks;
long ts = (dt1 - dt3) / 10000000;
DateTime ST = new DateTime(ts);
result - System.ArgumentOutOfRangeException: Ticks must be between DateTime.MinValue.Ticks and DateTime.MaxValue.Ticks.
Parameter name: ticks
long dt1 = DateTime.Now.Ticks;
long dt2 = procs.StartTime.Ticks;
long st = (dt1 - dt2)/10000000;
DateTime ST = new DateTime(st);
result - Arithmetic overflow error converting expression to data type datetime,
DateTime dt1 = DateTime.Now;
DateTime dt2 = procs.StartTime;
DateTime dt3 = new DateTime(1601, 1, 1, 0, 0, 0);
DateTime st = dt3.AddSeconds(dt2);
DateTime result = new DateTime(dt1.Subtract(st));
result - none
DateTime dt1 = DateTime.Now;
DateTime dt2 = procs.StartTime;
TimeSpan ts = dt1.Subtract(dt2);
DateTime result = DateTime.Now.Subtract(ts);
result - 01/01/1601 00:00:00
What am I missing?
|
|
|
|
|
CCodeNewbie wrote: What am I missing?
A clear description of what it is you want. Scrap all the code, write a text describing your goal first.
Then read my previous reply once more.
|
|
|
|
|
I would like to get the date & time that the process started.
The process start date/time is in nano seconds (Ticks) whose value is the difference between now and 01/01/1601 00:00:00 + the start date/time.
Thus, startdate/time = a
01/01/1601 00:00:00 = b
now = c
startdate/time = c - a + b
what is the syntax?
|
|
|
|
|
Wouldn't it be far easier to get that from the Process.StartTime property for the process in question?
Documentation can be found here[^].
|
|
|
|
|
Hi Dave,
The "System" process isn't enumerable as part of Process.GetProcesses. It has to be isolated.
I can get all the processes quite easily except for "Idle" - not enumerable & "System" - independently enumerable.
Thanks for your answer though.
|
|
|
|
|
CCodeNewbie wrote: I would like to get the date & time that the process started.
Err....
DateTime startTime = DateTime.Now;
|
|
|
|
|
Hi jschell,
Not sure that you mean.
The process started ~8 days ago but when I can't get that value from process.starttime because it is a tickcount.
Using a tickcount method I get many different answers, none of which are correct (when they don't error that is.
Using a timespan I get 150191.15:00:50.2796717 which is roughly 411 years ago. This means (to me) that the starttime is "stuck" at 1601,1,1,0,0,0.
It looks like the starttime is not directly enumerable as a datetime and has to be deduced.
Thanks for your reply.
|
|
|
|
|
CCodeNewbie wrote: Not sure that you mean.
When your application starts you collect that value.
You use it, not update it, after that.
|
|
|
|
|
Oh my.
1.
CCodeNewbie wrote: is in nano seconds (Ticks) no, ticks is not the same as nanoseconds.
2. forget about 1601, there were no computers back then. Use DateTime exclusively, without worrying about its origin. Just add ticks, seconds, or whatever it is you have.
3. from another of your posts, I get it your description is still no good, as you want to know when the idle process got launched, which amounts to when the system got booted. There is this[^] to handle that, mind you, they unfortunately have chosen a very confusing property name.
|
|
|
|
|
You shouldn't normally be messing around with ticks but since you already have that format:
final DateTime epochStart = new DateTime(1600, 01, 01, 0, 0, 0);
DateTime startTime = new DateTime(ticks - epochStart.Ticks);
And make sure that 'ticks' actually means the same thing. DateTime[^] thinks it means 100ns.
|
|
|
|
|
Hi Bob,
Thanks for your reply but I think you may have lost me a bit as I am not sure which of the examples you reply refers to.
I am also not familiar with "final" as VS2005 won't recognise the "DateTime" portion of "final DateTime epochStart"
Do you mean I should do something like:
long dt1 = DateTime.Now.Ticks;
long dt2 = procs.StartTime.Ticks;
long ticks = dt1 - dt2;
DateTime epochStart = new DateTime(1600, 01, 01, 0, 0, 0);
DateTime startTime = new DateTime(ticks - epochStart.Ticks);
Sorry if it's a stupid question but I have been around-and-around this problem so many times that I have lost a grip on it and was about to exclude the starttime value from the code altogether.
|
|
|
|