Split CSV to String Array
protected virtual string[] SplitCSV(string line)
{ System.Text.RegularExpressions.RegexOptions options = ((System.Text.RegularExpressions.RegexOptions.IgnorePatternWhitespace | System.Text.RegularExpressions.RegexOptions.Multiline)
| System.Text.RegularExpressions.RegexOptions.IgnoreCase);
Regex reg = new Regex("(?:^|,)(\\\"(?:[^\\\"]+|\\\"\\\")*\\\"|[^,]*)", options);
MatchCollection coll = reg.Matches(line);
string[] items = new string[coll.Count];
int i = 0;
foreach(Match m in coll)
{
items[i++] = m.Groups[0].Value.Trim('"').Trim(',').Trim('"').Trim();
}
return items;
}
More Recent Windows Development Articles:
Select Top XML Nodes using XPathThis example shows how to select Top N nodes of the specific name from an XML document.
Deserialize XML objectExample on how to Deserialize and XML object into a Class/Object
Read Connection String From DLL.config fileExample on how to read from a DLL's App Config - useful when using class library and you want the library to have its own app.config
Read Connection String From DLL.config fileExample on how to read from a DLL's App Config - useful when using class library and you want the library to have its own app.config
Thread PoolingThread Pooling Example
Embed image into emailDon't make your users download images with Outlook... Embed the image...
Basic number formatting specifiersString formating 101
Application location and the Microsoft Logo ProgramFollow the official Microsoft Guidelines with application location and the logo program
Encryption 101Encrypt and Decrypt strings of data to store into datbases, etc.
Making Images - Zip files and FTPMaking images and making zip files made easy. Add in FTP and you have a complete app
Indenty ImpersonationExample of Indenty Impersonation
Windows Commands such as logoff, reboot, shutdownExamples of dynamic Windows commands
Get User's Windows login nameGet User's Windows login name
Theading and the Internal ClassHow to use threading in your classes
Write to Application LogExample on how to write to the Windows Application Log file.
The Windows RegistryProgramming to the Windows Registry is simple!
Environmental VariablesHow to use Environmental Variables
Simple File watcherAn example of how to wait/watch for files changes
Regex ExampleUse Regex to match strings
Using License Providersadd license providers to your code
Using EnumerationsEnumerations are better than using plain integers...
Simple Active Directory ReaderMore and more AD is becoming a major part of system development.
Stored Procedure to DataSetThe beloved dataset. Here is an example on how to create and use them.
Exporting a datagrid object's data to ExcelExample on how to send data to Excel
Creating a dataset is simpleExample on how to create and use DataSets
SQL Connection StringHow to use SQL connections strings with both Web Applications and Windows Applications
Excel as a database - ADO.NetUtilized Excel's OleDB provider to work like SQL
Check and install software updatesHave your application check for software updates
DataGridView - Binding and FilterDataGridView - Binding and Filter
Fading Windows Notification FormIf you are a Office user, you know how cool the fading email notification form is. If you have not seen it, you will love it.
Single application - Only allow one version to runForce only a single instance of your application to work at a time
MDI & SDI Windows FormsExample on how to use and the difference between MDI and SDI windows forms
Windows Combo & List Box ClassEasy Windows Listbox/Combobox class object
CheckBoxesEasy Checkbox example
The error providerSimple method for windows Error management
Have you ever used the DOS command Net Send?This handy little tool will allow you to send Net Send messages to a group of people at once
ComboBox Key Down eventHow to capture and use key down events within the combo and listbox
Custom Log FileCreate your own log file
Open MS Word or any programExample on how to use System Process to open another program from C#.