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.
i want to get the path of the test.txt
what can i do
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")
System.IO.Path.GetDirectoryName("C:\temp\myfile.txt")
Can't find what you're looking for? Ask the community or share your knowledge.