path.Getfullpath

path.Getfullpath

Anonymous
Not applicable
673 Views
2 Replies
Message 1 of 3

path.Getfullpath

Anonymous
Not applicable

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 

0 Likes
674 Views
2 Replies
Replies (2)
Message 2 of 3

norman.yuan
Mentor
Mentor

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")

 

Norman Yuan

Drive CAD With Code

EESignature

Message 3 of 3

arcticad
Advisor
Advisor

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

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



(defun botsbuildbots() (botsbuildbots))
0 Likes