IO 磁碟總結

2022-04-20 17:56:28 字數 1368 閱讀 2566

io 磁碟

1.讀取

首先引用乙個using system.io;引用空間

其次

string ste= file.readalltext("e:\\bt.txt",encoding.default); //讀取

console.writeline(ste);

2.寫入

file.writealltext("e:\\bt.txt", "哈哈");

3.讀取二進位制檔案

file.readallbytes("e:\\bt.txt");

console.writeline("成功");

4.流檔案

filestream fs = new filestream("e:\\bt.txt",filemode.openorcreate,fileaccess.read);

streamreader dx = new streamreader (fs);//讀取流檔案

string i= dx.readtoend();

console.writeline(i);

5.檢視所有檔案當前

string u= directory.getfiles("c:");

for (int i = 0; i < u.length; i++)

反序列可以通過從儲存區中讀取或反序列化物件的狀態,重新建立該物件

反序列化:

1.定義乙個裝載物件的型別

2.建立乙個讀出檔案流

3.定義要反序列化的型別

4.呼叫反序列化方法

序列化格式例子

listinputlist = new list() ;

using (filestream fswriter = new filestream(@"tmp.dat",filemode.create,fileaccess.write))

反序列化

listinputlist = new list() ;

using (filestream fswriter = new filestream(@"tmp.dat",filemode.create,fileaccess.write))

xml序列化與反序列

listinputlist = new list() ;

using (filestream fswriter = new filestream(@"tmp.xml",filemode.create,fileaccess.write))

反序列化

listoutputlist = new list();

using (filestream fsreader = new filestream(@"tmp.xml",filemode.open,fileaccess.read))

磁碟 I O 效能

如果將 sql server 配置成僅包含幾個千兆位元組 gb 的資料,且不承擔繁重的讀或寫活動,便沒有太大的必要關注磁碟 i o 主題,以及在硬碟之間平衡 sql server i o 活動以獲取最佳效能。但是要建立包含成百上千 gb 位元組的資料且 或承擔繁重的讀和 或寫活動的大型 sql se...

監控磁碟IO

需求 阿里雲的機器,今天收到客服來的 說伺服器的磁碟io很重。於是登入到伺服器檢視,並沒有發現問題,所以懷疑是間歇性地。正要考慮寫個指令碼的時候,幸運的抓到了乙個線索,造成磁碟io很高的幕後 是mysql。此時去show processlist,但未發現有問題的佇列。原來只是一瞬間。只好繼續來寫指令...

磁碟io太高

在使用top命令的時候會看到這麼一行 us 使用者態使用的cpu時間比 sy 系統態使用的cpu時間比 ni 用做nice加權的程序分配的使用者態cpu時間比 id 空閒的cpu時間比 wa cpu等待磁碟寫入完成時間 hi 硬中斷消耗時間 si 軟中斷消耗時間 st 虛擬機器偷取時間 如果一台機器...