|
Learn from the mistakes of others, you may not live long enough to make them all yourself.
|
|
|
|
|
What about http://www.careerchange.com/[^]?
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
|
|
|
|
|
I myself made an assembly (TripleMachine.dll) that I just import whenever I need to triple a number. It has support for multithreading, for when I need to tripple large chunks of data.
boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);
|
|
|
|
|
hey, looks like my signature o.o
betonglasermur.FeedDwarf(pur_is, 17);
ProcessStartupInfo.AintNotCreateNoWindow = (false && !true) != (true || false) ? false == true ? true : false : (true != false && false);
Morgonen är tröttmans mecka
|
|
|
|
|
hey, that does not look like it isn't my signature
boolean dontNotCancel = ((!false && true) != (!true || false)) ? ((false == false || (true && (false == true ? true : false))) ? true : false) : (true != false && false);
|
|
|
|
|
|
I want to call cmd.exe from C# application and to change the directory from current directory.I have written code for this which is given below
------------------------------------------------------------------------------------------------------------------
//sample code //
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.ComponentModel;
namespace Console_sample
{
class Program
{
public void OpenWithArguments()
{
ProcessStartInfo startInfo = new ProcessStartInfo("CMD.exe");
Process p = new Process();
startInfo.RedirectStandardInput = true;
startInfo.UseShellExecute = false;
startInfo.RedirectStandardOutput = true;
startInfo.RedirectStandardError = true;
p = Process.Start(startInfo);
p.StandardInput.WriteLine(@"Echo on");
p.StandardInput.WriteLine(@"dir " + @"C:");
p.StandardInput.WriteLine(@"chdir " + @"C:\WINDOWS ");
p.StandardInput.WriteLine(@"EXIT");
string output = p.StandardOutput.ReadToEnd();
string error = p.StandardError.ReadToEnd();
p.WaitForExit();
Console.Write(output);
p.Close();
Console.Read();
}
static void Main(string[] args)
{
Program myProcess = new Program();
myProcess.OpenWithArguments();
}
}
}
--------------------------------------------------------------------------------------
In the console I got following output
-----------------------------------------------------------------------------------------------------------
D:\Program\Console_sample\bin\Debug>Echo on
D:\Program\Console_sample\bin\Debug>dir C:
Volume in drive C has no label.
Volume Serial Number is F06C-447B
Directory of C:\Program Files\Microsoft Visual Studio 8\Common7\IDE
04/24/2008 05:17 PM <DIR> .
04/24/2008 05:17 PM <DIR> ..
03/26/2008 04:02 PM <DIR> 1033
D:\Program\Console_sample\bin\Debug>chdir C:\WINDOWS
D:\Program\Console_sample\bin\Debug>EXIT
---------------------------------------------------------------------------------
where my directory is not chaged while the DIR command got perfectly executed .How can i fix this ?Even i notice that when i write p.standardInput.writeline(@"date"); it doean't show me the date also.please provide solutuion for this .if anyone has sample code for executing cmd command from C# .net will be very useful.
any help appreciated
thanks in advance
|
|
|
|
|
The line you've written:
<br />
p.StandardInput.WriteLine(@"chdir " + @"C:\WINDOWS ");<br />
This will take effect:
<br />
p.StandardInput.WriteLine(@"chdir /d" + @"C:\WINDOWS ");<br />
|
|
|
|
|
Hey guys...
i have an console app that calls a different console app, im trying to get the result of the 2nd app printed in the 1st app.
heres my current code
Process myProcess = new Process();
myProcess.StartInfo.UseShellExecute = false;
myProcess.StartInfo.RedirectStandardOutput = true;
myProcess = Process.Start("ring.exe");
Console.WriteLine("Started 1st process --> Waiting............ ");
myProcess.WaitForExit();
StreamReader sr = myProcess.StandardOutput;
Console.WriteLine("Finnished 1st process ---> output:");
Console.WriteLine(sr.ReadToEnd());
im getting the following error at runtime "StandardOut has not been redirected or the process hasn't started yet."
any ideas what im doing wrong?
thanx
Harvey Saayman - South Africa
Junior Developer
.Net, C#, SQL
think BIG and kick ASS
you.suck = (you.passion != Programming)
|
|
|
|
|
try this:
<br />
System.Diagnostics.ProcessStartInfo psi = new System.Diagnostics.ProcessStartInfo("cmd.exe");<br />
System.Diagnostics.Process p = new System.Diagnostics.Process();<br />
psi.RedirectStandardOutput = true;<br />
psi.UseShellExecute = false;<br />
p.StartInfo = psi;<br />
p.Start();<br />
p.WaitForExit();<br />
System.IO.StreamReader sr = p.StandardOutput;<br />
MessageBox.Show("Finnished 1st process ---> output:");<br />
MessageBox.Show(sr.ReadToEnd());<br />
|
|
|
|
|
i want to check through my C# code, Pen Drive Connect to computer yes or not only.
|
|
|
|
|
I don't think there's an event for that, but you CAN iterate over available drives and work out if any are removable. DriveInfo[] drives = DriveInfo.GetAllDrives() ( something like that ). Then, each one has an enum that tells you if it's a HDD, if it's optical, if it's removable.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
|
Hi,
Can someone try to tell me the definitive (like, yeah) way of sending a mail in c# from my website. I'm .NET2, Visual Sudio 2005 and have a 3 simple textboxs and a send button on my site for people to get in touch. I want it to send me the text1 as a subject, text2 as the body, text3 as their mail address (which they have manually typed in)
Obviously I've been round the web.....
private void Button1_Click(object sender, System.EventArgs e)
{
MailMessage mail = new MailMessage();
mail.To = txtTo.Text;
mail.From = txtFrom.Text;
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
}
these seem out of date, and how do I test locally on my machine? Do I put 'localhost' as my SMTP server? until it goes live?
Any help would be great.
Thanks
Harvey
|
|
|
|
|
imnotso# wrote: MailMessage mail = new MailMessage();
mail.To = txtTo.Text;
mail.From = txtFrom.Text;
mail.Subject = txtSubject.Text;
mail.Body = txtBody.Text;
SmtpMail.SmtpServer = "localhost";
SmtpMail.Send(mail);
This is obsolete now. Use classes in System.Net.Mail namespace. You can configure System.Net.Mail settings on the app.config file and put the server name as localhost . Stop local SMTP server and set mail delivery type as PickupDirectoryFromIis which will deliver mails to the pickup directory.
|
|
|
|
|
Thanks for that,
In the new classes I cannot find where I specify the SMTP server name. Any ideas?
Harvey
|
|
|
|
|
Plus 'localhost' always returns an error.
|
|
|
|
|
Then I guess you found where to put it ? You need an actual mail server, in order to send mail.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Yeah, thanks.
Why is everyone mentioning 'localhost' if it's not a vaible option i wonder? Can I just use any server until I put it live?
Thanks
|
|
|
|
|
It's possible to set up a mail server on our local machine. You can put whatever you like, but it won't work, obviously.
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
I'm not sure how it can be tested then without putting it live, that cannot be right surely?
|
|
|
|
|
How do you hope to send mail, without a mail server ? You cannot. I don't see the issue, your mail server is not 'live', it's the server that sends your mail ( i.e. you can use the mail server from your ISP, the one that your Outlook uses ).
Christian Graus
Please read this if you don't understand the answer I've given you
"also I don't think "TranslateOneToTwoBillion OneHundredAndFortySevenMillion FourHundredAndEightyThreeThousand SixHundredAndFortySeven()" is a very good choice for a function name" - SpacixOne ( offering help to someone who really needed it ) ( spaces added for the benefit of people running at < 1280x1024 )
|
|
|
|
|
Just for testing purpose you can use localhost as server and delivery method as Pickup directory. So all the mails sent are kept in pickup directory as outlook file format. You can goto that directory and easily check the mail. Once you are ready to release the application, change delivery method to Network and specify valid SMTP server details and credentials. Read details about SMTPClient here[^]. Read and excellent FAQ on System.Net.Mail here[^]. Also this[^] explains how to configure your application configuration file.
|
|
|
|
|
Thank you, I thought it was possible. many thanks again....
|
|
|
|
|