Tag Archives: C

Opening a folder at C#

To open a folder in C#, simply follow the following example :

[code lang="csharp"]
private void openFolder()
{
string myDocspath = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);// if you are after special documents (e.g. my documents)
string myFolderpath = Application.StartupPath + "\\folderName\\"; // a folder right beside where you run the program
string windir = Environment.GetEnvironmentVariable("WINDIR");
System.Diagnostics.Process process = new System.Diagnostics.Process();
process .StartInfo.FileName = windir + @"\explorer.exe";
process .StartInfo.Arguments = myFolderpath;
process .Start();//OPEN the folder
}
[/code]


Source

How to Export Data to Excel without hassel

Saving query to excel format could go through Microsoft Office Interop services or some third party libraries. However there is a simpler way. CSV file formats are wuite simple and one could simply read queries and save them into a text file format with CSV as the extension (myfile.csv).

The tricks would be to have the data read from database by query and write each record as a line and semicolon to separate the column vales.This is actually language independent and one could implement it by C#, Java or any other language that could execute queries on a database.

String to Double issues in C# .NET

If you are simply using

double test = Double.Parse(“12.45″);

and it doesn’t work due to formating issues, here is the right post for you. Almost certainly you’re using the wrong CultureInfo. Try specifying CultureInfo.InvariantCulture to parse in. I suspect it’s currently assuming that “.” is a thousands separator rather than a decimal point.

CultureInfo Invc = new CultureInfo(“”);
Invc = CultureInfo.InvariantCulture;
x1 = Double.Parse(“12.45″, Invc);

alternative:

x1 = Double.Parse(“12.45″, CultureInfo.InvariantCulture);

OpenCV installation Tutorial, MS Visual C++ 2008

Installing OpenCV might sound very easy when you read it on some forums/websites, but there are some small changes in most of these tutorials that prevent the connection between OpenCV and MS Visual C++. In this tutorial we(my dear friend Puya Afsharian and I) try to guide you through the installation of these two products and the right way to make them talk with each other.

Although people say it is easy to make OpenCV 2.2 to work with MS Visual C++ 2010, but we did not get it to work properly while it seems that MS visual c++ 2008 works perfect with OpenCV 2.1. Here are the download links for both products :

OpenCV 2.1 : http://sourceforge.net/projects/opencvlibrary/files/opencv-win/2.1/
This file is modified to work with MS Visual C++ 2008 and therefore there is no need to install CMake again.

MS Visual C++ 2008(Free of charge) : http://www.microsoft.com/downloads/en/details.aspx?familyid=a5c84275-3b97-4ab7-a40d-3802b2af5fc2&displaylang=en

Click More down here to read the rest of the tutorial …

Continue reading