How do I find out what directory my console app is running in?
To get the directory where the .exe file is: AppDomain.CurrentDomain.BaseDirectory To get the current directory: Environment.CurrentDirectory
To get the directory where the .exe file is: AppDomain.CurrentDomain.BaseDirectory To get the current directory: Environment.CurrentDirectory
Regular Expression evaluation can be done using DataTable.Compute method (from MSDN) : Computes the given expression on the current rows that pass the filter criteria. Try this: using System.Data;//import this namespace string math = “100 * 5 – 2”; string value = new DataTable().Compute(math, null).ToString();
Right now, you’re checking whether the sentence as a whole contains any vowels, once for each character. You need to instead check the individual characters. for (int i = 0; i < sentence.Length; i++) { if (sentence[i] == ‘a’ || sentence[i] == ‘e’ || sentence[i] == ‘i’ || sentence[i] == ‘o’ || sentence[i] == ‘u’) … Read more
You can’t do this. You can’t pass the table name as a parameter the way you did: SqlCommand com = new SqlCommand(“insert into @table …”); … com.Parameters.AddWithValue(“@table”, tblname); You can do this instead: Console.WriteLine(“Enter table name:”); Console.Write(“>> “); string tblname = Console.ReadLine(); string sql = String.Format(“insert into {0} (time, date, pin) values … “, tblname); … Read more
Update Now that ASP.NET Core is out there are a few ways to Self Host a web application. One option is to use an OWIN based web server such as Nowin. var host = new WebHostBuilder() .UseNowin() .UseContentRoot(Directory.GetCurrentDirectory()) .UseStartup<Startup>() .Build(); Alternatively, Kestrel has also been a popular choice for hosting ASP.NET Core applications. var host … Read more
You just compile it. In the bin\Release (or bin\Debug) folder, the .exe will be in there. If you’re asking how to make an executable which does not rely on the .NET framework at all, then that’s a lot harder and you’ll need to purchase something like RemoteSoft’s Salamader. In general, it’s not really worth the … Read more
Inside your project folder their is a bin folder. Inside your bin folder, there are 2 folders, a Release and a Debug. For your polished .exe, you want to go into your Release folder. I’m not quite sure if thats what youre asking
It means that you don’t have a suitable entry point for your application at the moment. That code will nearly work with C# 7.1, but you do need to explicitly enable C# 7.1 in your project file: <LangVersion>7.1</LangVersion> or more generally: <LangVersion>latest</LangVersion> You also need to rename MainAsync to Main. So for example: Program.cs: using … Read more
This because you read a char. Use appropriate methods like ReadInt32() that takes care of a correct conversion from the read symbol to the type you wish. The reason why you get 49 is because it’s a char code of the ‘1’ symbol, and not it’s integer representation. char code 0 : 48 1 : … Read more
The ThreadPool is specifically not intended for long-running items (more specifically, you aren’t even necessarily starting up new threads when you use the ThreadPool, as its purpose is to spread the tasks over a limited number of threads). If your task is long running, you should either break it up into logical sections that are … Read more