Hide console window from Process.Start C#

I had a similar issue when attempting to start a process without showing the console window. I tested with several different combinations of property values until I found one that exhibited the behavior I wanted. Here is a page detailing why the UseShellExecute property must be set to false. http://msdn.microsoft.com/en-us/library/system.diagnostics.processstartinfo.createnowindow.aspx Under Remarks section on page: … Read more

How to navigate a few folders up?

Other simple way is to do this: string path = @”C:\Folder1\Folder2\Folder3\Folder4″; string newPath = Path.GetFullPath(Path.Combine(path, @”..\..\”)); Note This goes two levels up. The result would be: newPath = @”C:\Folder1\Folder2\”; Additional Note Path.GetFullPath normalizes the final result based on what environment your code is running on windows/mac/mobile/…

How to write Unicode characters to the console?

It’s likely that your output encoding is set to ASCII. Try using this before sending output: Console.OutputEncoding = System.Text.Encoding.UTF8; (MSDN link to supporting documentation.) And here’s a little console test app you may find handy: C# using System; using System.Text; public static class ConsoleOutputTest { public static void Main() { Console.OutputEncoding = System.Text.Encoding.UTF8; for (var … Read more

Why is the console window closing immediately once displayed my output?

the issue here is that their Hello World Program is showing up then it would immediately close. why is that? Because it’s finished. When console applications have completed executing and return from their main method, the associated console window automatically closes. This is expected behavior. If you want to keep it open for debugging purposes, … Read more

Can I write into the console in a unit test? If yes, why doesn’t the console window open?

Someone commented about this apparently new functionality in Visual Studio 2013. I wasn’t sure what he meant at first, but now that I do, I think it deserves its own answer. We can use Console.WriteLine normally and the output is displayed, just not in the Output window, but in a new window after we click “Output” in … Read more

.NET Global exception handler in console application

No, that’s the correct way to do it. This worked exactly as it should, something you can work from perhaps: using System; class Program { static void Main(string[] args) { System.AppDomain.CurrentDomain.UnhandledException += UnhandledExceptionTrapper; throw new Exception(“Kaboom”); } static void UnhandledExceptionTrapper(object sender, UnhandledExceptionEventArgs e) { Console.WriteLine(e.ExceptionObject.ToString()); Console.WriteLine(“Press Enter to continue”); Console.ReadLine(); Environment.Exit(1); } } Do keep … Read more

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)