Some really cool. NET Tips

Source: Internet
Author: User

I.. Net Framework

1. How to obtain a system folder

Use the GetFolderPath method of the System.envioment class, for example:

Environment.getfolderpath (Environment.SpecialFolder.Personal)

2. How to get the path of an EXE file being executed

1 using the ExecutablePath property of the application class

2) System.Reflection.Assembly.GetExecutingAssembly (). Location

3. How to detect the version of the operating system

Use the OSVersion property of Envioment, for example:

OperatingSystem os = Environment.OSVersion;
MessageBox.Show(os.Version.ToString());
MessageBox.Show(os.Platform.ToString());

4. How to obtain the file name portion of the document based on the full file name,

Methods for using the System.IO.Path class GetFileName or Getfilenamewithoutextension methods

5. How to obtain the file extension through the full name of the file

Using the System.IO.Path.GetExtension static method

6. What is the difference between VB and C # 's syntax click here

7. How to get the current computer user name, whether networking, several monitors, the domain, the mouse has several keys and other information

Use static properties of the System.Windows.Forms. SystemInformation class

8. What is the effect of the [STAThread] attribute of the modifier main method

To indicate that the current program is running in a single threaded way

9. How to read the contents of a CSV file

Through OdbcConnection you can create a link to a CSV file that is formatted as "Driver={microsoft Text Driver (*.txt;*.csv)};D bq=" +cvs file Folder path + " Extensions=asc,csv,tab,txt; Persist security Info=false ";

After you create the connection, you can use DataAdapter to access the CSV file.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.