Share vb.net get file extension

## VB.NET ## Nhận tiện ích mở rộng tệp ## Tiện ích mở rộng tệp ## VB.NET Hướng dẫn ## Mã hóa

### Cách nhận tiện ích mở rộng tệp trong vb.net

Phần mở rộng tệp là một chuỗi xuất hiện sau khoảng thời gian cuối cùng (.) Trong một tên tệp.Ví dụ: tên tệp "myfile.txt" có phần mở rộng tệp ".txt".

Trong vb.net, bạn có thể nhận tiện ích mở rộng tệp bằng phương thức ** getExtension ** của lớp ** system.io.fileInfo **.Phương thức ** getExtension ** trả về một chuỗi đại diện cho phần mở rộng tệp.

Mã sau đây cho thấy cách lấy phần mở rộng tệp của tệp:

`` `VBNet
Dim FileInfo dưới dạng System.io.fileinfo ("myfile.txt")
Dim Fileextension as String = FileInfo.Extension
`` `

Biến ** fileextension ** bây giờ sẽ chứa giá trị ".txt".

Bạn cũng có thể sử dụng phương thức ** path.getextension ** để lấy phần mở rộng tệp.Phương thức ** path.getextension ** Trả về một chuỗi đại diện cho phần mở rộng tệp, không có thời gian dẫn đầu (.).

Mã sau đây cho thấy cách lấy phần mở rộng tệp của tệp bằng phương thức ** path.getextension **:

`` `VBNet
Dim Fileextension as String = path.getextension ("myfile.txt")
`` `

Biến ** fileextension ** giờ đây sẽ chứa giá trị "txt".

### hashtags

* #vb.net
* Phần mở rộng tệp #Get
* Phần mở rộng #file
* #vb.net Hướng dẫn
* #mã hóa
=======================================
##VB.NET ##Get File Extension ##File Extension ##VB.NET Tutorial ##Coding

### How to Get File Extension in VB.NET

The file extension is a string that appears after the last period (.) in a file name. For example, the file name "myfile.txt" has the file extension ".txt".

In VB.NET, you can get the file extension using the **GetExtension** method of the **System.IO.FileInfo** class. The **GetExtension** method returns a string that represents the file extension.

The following code shows how to get the file extension of a file:

```vbnet
Dim fileInfo As New System.IO.FileInfo("myfile.txt")
Dim fileExtension As String = fileInfo.Extension
```

The **fileExtension** variable will now contain the value ".txt".

You can also use the **Path.GetExtension** method to get the file extension. The **Path.GetExtension** method returns a string that represents the file extension, without the leading period (.).

The following code shows how to get the file extension of a file using the **Path.GetExtension** method:

```vbnet
Dim fileExtension As String = Path.GetExtension("myfile.txt")
```

The **fileExtension** variable will now contain the value "txt".

### Hashtags

* #vb.net
* #Get File Extension
* #file Extension
* #vb.net Tutorial
* #Coding
 
Join Telegram ToolsKiemTrieuDoGroup
Back
Top