.NET
cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

path.Getfullpath

2 REPLIES 2
Reply
Message 1 of 3
hoyin0820
499 Views, 2 Replies

path.Getfullpath

Dim filename As String = "Test.txt"
Dim fullPath As String
fullPath = Path.GetFullPath(filename)
MsgBox("GetFullPath('{0}') returns '{1}'", _
filename, fullPath)

 

i try it but it has error on ((MsgBox("GetFullPath('{0}') returns '{1}'", filename, fullPath)))

Conversion from string "Desktop\Layer Data\Test.txt" to type 'Integer' is not valid.

 

want to get the path of the test.txt

 

what can i do 

2 REPLIES 2
Message 2 of 3
norman.yuan
in reply to: hoyin0820

Well, to me it is another sample of VB doing much on behalf of user behind the scenewhile "Option Strict" is not turned on (by default). If "Option Strict" is turned on, the compiling would have failed on the line of code: the parameters you passed to MsgBox, the second one, is wrong. It should be a MsgBoxStyle enum value - an integer, indicating the button(s) showing, such as OKOnly, YesNo,...Thus the error message. If you use C#, you'll never be puzzled by such low level error, the compiler always causes it.

 

MsgBox function does not have the same method signature as Strinig.Format(), or Editor.WriteMessage(), as your code shows.

 

In your code, you should

 

Dim msg As String=String.Format("GetFullPath('{0}') returns '{1}'", fileName,filePath)

MsgBox(msg, MsgBoxStyle.OkOnly,"My Message")

 

Message 3 of 3
arcticad
in reply to: hoyin0820

System.IO.Path.GetDirectoryName("C:\temp\myfile.txt")

---------------------------



(defun botsbuildbots() (botsbuildbots))

Can't find what you're looking for? Ask the community or share your knowledge.

Post to forums  

Autodesk DevCon in Munich May 28-29th


Autodesk Design & Make Report

”Boost