麻豆小视频在线观看_中文黄色一级片_久久久成人精品_成片免费观看视频大全_午夜精品久久久久久久99热浪潮_成人一区二区三区四区

首頁 > 編程 > .NET > 正文

編程技巧:.Net Framework

2024-07-21 02:30:09
字體:
來源:轉載
供稿:網友

.net framework

1. 如何獲得系統文件夾

使用system.envioment類的getfolderpath方法;例如:

environment.getfolderpath( environment.specialfolder.personal )

2. 如何獲得正在執行的exe文件的路徑

1) 使用application類的executablepath屬性

2) system.reflection.assembly.getexecutingassembly().location

3. 如何檢測操作系統的版本

使用envioment的osversion屬性,例如:

operatingsystem os = environment.osversion;

messagebox.show(os.version.tostring());

messagebox.show(os.platform.tostring());

4. 如何根據完整的文件名獲得文件的文件名部分

使用system.io.path類的方法getfilename或者getfilenamewithoutextension方法

5. 如何通過文件的全名獲得文件的擴展名

使用system.io.path.getextension靜態方法

6. vb和c#的語法有什么不同click here

7. 如何獲得當前電腦用戶名,是否聯網,幾個顯示器,所在域,鼠標有幾個鍵等信息

使用system.windows.forms. systeminformation類的靜態屬性

8. 修飾main方法的[stathread]特性有什么作用

標示當前程序使用單線程的方式運行

9. 如何讀取csv文件的內容

通過odbcconnection可以創建一個鏈接到csv文件的鏈接,鏈接字符串的格式是:"driver={microsoft text driver (*.txt;*.csv)};dbq="+cvs文件的文件夾路徑+" extensions=asc,csv,tab,txt; persist security info=false";

創建連接之后就可以使用dataadapter等存取csv文件了。

詳細信息見此處

10. 如何獲得磁盤開銷信息,代碼片斷如下,主要是調用kernel32.dll中的getdiskfreespaceex外部方法。

public sealed class driveinfo
{
[dllimport("kernel32.dll", entrypoint = "getdiskfreespaceexa")]
private static extern long getdiskfreespaceex(string lpdirectoryname,
out long lpfreebytesavailabletocaller,
out long lptotalnumberofbytes,
out long lptotalnumberoffreebytes);

public static long getinfo(string drive, out long available, out long total, out long free)
{
return getdiskfreespaceex(drive, out available, out total, out free);
}

public static driveinfosystem getinfo(string drive)
{
long result, available, total, free;
result = getdiskfreespaceex(drive, out available, out total, out free);
return new driveinfosystem(drive, result, available, total, free);
}
}

public struct driveinfosystem
{
public readonly string drive;
public readonly long result;
public readonly long available;
public readonly long total;
public readonly long free;

public driveinfosystem(string drive, long result, long available, long total, long free)
{
this.drive = drive;
this.result = result;
this.available = available;
this.total = total;
this.free = free;
}
}

可以通過driveinfosystem info = driveinfo.getinfo("c:");來獲得指定磁盤的開銷情況

11.如何獲得不區分大小寫的子字符串的索引位置

1)通過將兩個字符串轉換成小寫之后使用字符串的indexof方法:

string strparent = "the codeproject site is very informative.";

string strchild = "codeproject";

// the line below will return -1 when expected is 4.
int i = strparent.indexof(strchild);

// the line below will return proper index
int j = strparent.tolower().indexof(strchild.tolower());

2) 一種更優雅的方法是使用system.globalization命名空間下面的compareinfo類的indexof方法:

using system.globalization;

string strparent = "the codeproject site is very informative.";

string strchild = "codeproject";
// we create a object of compareinfo class for a neutral culture or a culture insensitive object
compareinfo compare = cultureinfo.invariantculture.compareinfo;

int i = compare.indexof(strparent,strchild,compareoptions.ignorecase);

國內最大的酷站演示中心!
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 国产免费小视频在线观看 | 国产在线1区 | 精品亚洲夜色av98在线观看 | 超碰99在线观看 | 黄色影院在线观看视频 | 在线成人免费观看www | 羞羞草视频| av影院在线播放 | 免费视频一区 | 色无极影院亚洲 | 天天干导航 | 欧美日韩国产一区二区三区在线观看 | 精品国产一区二区三区久久久蜜月 | 国内精品伊人久久 | 欧美黄色大片免费观看 | 毛片视频网站 | 亚洲精品午夜国产va久久成人 | 91天堂国产在线 | 精品一区二区三区免费看 | 久久国产精品免费视频 | 亚洲国产精品一 | 中文字幕观看 | 2017亚洲男人天堂 | 黄色伊人网站 | 91九色免费视频 | av成人免费看 | 欧美爱爱视频网站 | 久国产 | 日韩欧美精品中文字幕 | 激情小说激情图片激情电影 | 欧美aⅴ视频 | 免费99热在线观看 | 国产一国产一级毛片视频在线 | 欧美日韩一 | 男人的天堂毛片 | 色中色激情影院 | china对白普通话xxxx | 黄色免费在线网站 | 国产喷白浆10p | 羞羞视频免费网站日本动漫 | 成人在线网站 |