简体   繁体   中英

Formatting a file path text in VB for textbox

Lets say i have 2 buttons "btnBrowse" and "btnImport", i also have a label "lbPath" and a textbox "txtSubject"

When i click browse, the application allows me to look for a file and import the data to a grid view. So i click btnBrowse, find the excel file, double click it, then click btnImport. 4 things happen when i click "btnImport"

1: lbPath.Text changes to the path of the file i picked "C:\\Users\\me\\Desktop\\excel.xlsx" 2: The gridview loads the excel file data 3: txtSubject.Text changes to the path of the file as well "C:\\Users\\me\\Desktop\\excel.xlsx" 4: the path name becomes the variable "spath" as a string

I would like 1 and 2 to stay the same but for txtSubject.Text, i would like it to grab the last part of the path so the results would be as follows

1: lbPath.Text = "C:\\Users\\me\\Desktop\\excel.xlsx" 2: The gridview loads the excel file data 3: txtSubject.Text = "excel.xlsx"

Any ideas?

这是执行此操作的方法:

txtSubject.Text = System.IO.Path.GetFileName(lbPath.Text)

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM