TextFieldParser.SetFieldWidths(Int32[]) 方法
定義
重要
部分資訊涉及發行前產品,在發行之前可能會有大幅修改。 Microsoft 對此處提供的資訊,不做任何明確或隱含的瑕疵擔保。
將讀取器的分隔符設定為指定的值。
public:
void SetFieldWidths(... cli::array <int> ^ fieldWidths);
public void SetFieldWidths(params int[] fieldWidths);
member this.SetFieldWidths : int[] -> unit
Public Sub SetFieldWidths (ParamArray fieldWidths As Integer())
參數
- fieldWidths
- Int32[]
的 Integer陣列。
範例
此範例開啟一個文字欄位解析器,並將欄位寬度定義為 5。
Using FileReader As New Microsoft.VisualBasic.FileIO.
TextFieldParser("C:\logs\test.log")
FileReader.SetFieldWidths(5)
End Using
將路徑 C:\logs\test.log 替換成你想解析的檔案的路徑和名稱。
以下範例開啟一個文字欄位解析器,並定義欄位寬度為 5、 、 10和 變數。
Using MyReader As New Microsoft.VisualBasic.FileIO.
TextFieldParser("C:\logs\test.log")
MyReader.SetFieldWidths(5, 10, -1)
End Using
將路徑 C:\logs\test.log 替換成你想解析的檔案的路徑和名稱。
備註
當此設定完成後,現有的財產 Delimiters 內容物會被清空。
此方法提供一種設定分隔符而無需建立陣列的方法。
下表列出了與此 SetFieldWidths 方法相關的任務範例。
| 至 | 看! |
|---|---|
| 解析一個文字檔。 | 使用 TextFieldParser 物件剖析文字檔 |