vb.net - VB Console application to rename a file -
i trying write console application in vb allow me change name of file.
the code have far is:
public class form1 private sub btnrename_click(byval sender system.object, byval e system.eventargs) handles btnrename.click if txtpath.text.length <> 0 , txtname.text.length <> 0 ' change "c:\test.txt" path , filename file ' want rename. ' txtpath contains full path file ' txtname contains new name my.computer.filesystem.renamefile(txtpath.tostring, txtname.tostring) else messagebox.show("please fill fields", "error", messageboxbuttons.ok, messageboxicon.warning) end if end sub private sub btnclear_click(byval sender system.object, byval e system.eventargs) handles btnclear.click txtpath.clear() txtname.clear() end sub end class
but when try run error in line:
my.computer.filesystem.renamefile(txtpath.tostring, txtname.tostring)
any suggestions?
changing :
my.computer.filesystem.renamefile(txtpath.tostring, txtname.tostring)
to:
my.computer.filesystem.renamefile(txtpath.text.tostring, txtname.text.tostring)
solves problem.
Comments
Post a Comment