If you want to remove invalid chars "* . " / \ [ ] : ; | = ," from file name below is the code which can help you Sample code: using System; using System.IO; using System.Text.RegularEx...
In this blog I will show you how to swap two integer variables. I will be using Interlocked.Exchange to do the same: using System; using System.Threading; namespace SampleConsoleApplication { class Pr...
In this blog I will show how to replace single backslash with double backslash in a string with REGEX. Let's say we have a string "This is \ test \ string" and we want to replace single ...
In this blog I will show how to replace uppercase letter with "underscore and the letter "in a string with REGEX. Let's say we have a string "ThisIsTestString" and we want to r...
In this blog I will show how to validate a string to allow alphanumeric characters only in a string with REGEX. Below is the sample code to do the same: using System; using System.Text.RegularExpressi...
In this blog I will show how to remove all non numeric characters from a string with REGEX. Let's say we have a string "(912)-555-7777" and remove all non numeric characters so that the ...
In this blog I will show how to remove all non alpha numeric characters from a string with REGEX. Let's say we have a string "Hello!@#$123456789~~-_user456welcome" and remove all non alp...
In this blog I will show how to reverse all numbers in string with REGEX. Let's say we have a string "Hello 123456789 user 456 welcome." and we want to reverse it like "Hello 987654...
I encountered a piece of code where regex replacement was done in the following way: Regex.Replace(@"\d+", m => new string(m.Value.Reverse().ToArray())); It was giving the following e...
While using Directory.GetFiles I started getting the following excpetion Path too long error message when exceeding MAX_PATH Luckily I came across the following library: Delimon.Win32.IO Library (V4....
While using the File.Move method to move a file from one location to other: File.Move(oldPath, newPath); I was getting the following exception: Access to the path is denied. Exception Details: System....
Below is the code which can help you to copy all the folders and files of a directory to a backup folder inside it. Let's create a helper class to do the same: #region Using Directives using Syste...
I was working with a program noticed where I needed to use curly itself inside a string and string.format was not wroking with it. I was having the following sting: string myString = string.Format(&qu...
If you are using Windows Authentication and want to avoid the login prompt which comes when you try to access the application this blog will help you. The solution I am writing below is only for IE. I...
Lets say we have two classes Person1 and Person2. Below is the code for it: public class Person1 { public int ID { get; set; } public string Name { get; set; } public string FirstName { get; set; } pu...
While parsing one of my regex pattern based on input data I was getting the following error: RegEx: Quantifier {x,y} following nothing error I was having the following code: string pattern = string.Fo...
While working with transmitting files via server side was not working when filename was having space
In order to get mimetype/contenttype from file name/extension you need to make use of "System.Web.Mi
The reason of this issue is that on 64 bit process uses WOW64 folder. You need to write the code whi
I will show you how to get connecting string stored in registry. The code which I will show in this
Considering all subdirectories: string directoryPhysicalPath="xxxx"; string[] files = Directory.GetF
http://stackoverflow.com/questions/9/how-do-i-calculate-someones-age-in-c
A person asked me today whether Lazy<T>(Func<T>) thread safe or not? He was having this
Today I was facing one issue where I was trying to delete a cookie which was created from parent sit
While working with WCF application today I was getting the following ProtocolViolationException- Can