Is Mono ready for prime time? [closed]

There are a couple of scenarios to consider: (a) if you are porting an existing application and wondering if Mono is good enough for this task; (b) you are starting to write some new code, and you want to know if Mono is mature enough. For the first case, you can use the Mono Migration … Read more

Get current folder path

You should not use Directory.GetCurrentDirectory() in your case, as the current directory may differ from the execution folder, especially when you execute the program through a shortcut. It’s better to use Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location); for your purpose. This returns the pathname where the currently executing assembly resides. While my suggested approach allows you to differentiate between the … Read more

.NET Core vs Mono

Necromancing. Providing an actual answer. What is the difference between .Net Core and Mono? .NET Core now officially is the future of .NET. It started for most part with a re-write of the ASP.NET MVC framework and console applications, which of course includes server applications. (Since it’s Turing-complete and supports interop with C dlls, you … Read more

How can I create a temp file with a specific extension with .NET?

Guaranteed to be (statistically) unique: string fileName = System.IO.Path.GetTempPath() + Guid.NewGuid().ToString() + “.csv”; (To quote from the wiki article on the probabilty of a collision: …one’s annual risk of being hit by a meteorite is estimated to be one chance in 17 billion [19], that means the probability is about 0.00000000006 (6 × 10−11), equivalent … Read more

Upload files with HTTPWebrequest (multipart/form-data)

Took the code above and fixed because it throws Internal Server Error 500. There are some problems with \r\n badly positioned and spaces etc. Applied the refactoring with memory stream, writing directly to the request stream. Here is the result: public static void HttpUploadFile(string url, string file, string paramName, string contentType, NameValueCollection nvc) { log.Debug(string.Format(“Uploading … Read more

How do you UrlEncode without using System.Web?

System.Uri.EscapeUriString() can be problematic with certain characters, for me it was a number / pound ‘#’ sign in the string. If that is an issue for you, try: System.Uri.EscapeDataString() //Works excellent with individual values Here is a SO question answer that explains the difference: What’s the difference between EscapeUriString and EscapeDataString? and recommends to use … Read more

Getting file names without extensions

You can use Path.GetFileNameWithoutExtension: foreach (FileInfo fi in smFiles) { builder.Append(Path.GetFileNameWithoutExtension(fi.Name)); builder.Append(“, “); } Although I am surprised there isn’t a way to get this directly from the FileInfo (or at least I can’t see it).

How do I find the .NET version?

There is an easier way to get the exact version .NET version installed on your machine from a cmd prompt. Just follow the following instructions; Open the command prompt (i.e Windows + R → type “cmd”). Type the following command, all on one line: reg query “HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\NET Framework Setup\NDP” (This will list all the .NET … Read more

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