Strings won't concat?

G

Guest

In the following function, after adding the filename to the path, the
filename is not there. Even if I try to add the filename in the calling sub
or function, the filename is not there.

While debugging, I notice that the tooltip that shows the value for "out"
does not have a trailing quotation mark. I don't know why and I can't figure
out how to successfully concat the path and the filename!!

Can anyone help???

Thanks in advance!

Public Declare Function WNetGetConnection Lib "mpr.dll" Alias _
"WNetGetConnectionA" (ByVal lpszLocalName As String, _
ByVal lpszRemoteName As String, ByRef cbRemoteName As Integer)
As Integer

Private Function GetUNCPathFromMappedDriveLetter(ByVal MappedLetter As
String, ByVal Filename As String) As String
Try
'MappedLetter arg must be of form "C:"

'get the UNC path and return it
Dim ret As Integer
Dim out As String = New String(" "c, 260)
Dim len As Integer = 260

ret = WNetGetConnection(MappedLetter, out, len)

out = out.TrimEnd(" "c)

Return out & Filename '<--------------Filename is not returned!!??
'Return String.Concat(out,filename) 'also does not work
Catch ex As Exception
MsgBox(ex.ToString)
End Try
End Function
 
C

Cor Ligthert [MVP]

KSC.

It can be that Out has a 00 character in it. Everything behind that is not
showed.

Just an idea

Cor
 
G

Guest

That was it Cor. Thank you.

Changed line "out = out.TrimEnd(" "c)"

to

"out = out.TrimEnd(" "c).TrimEnd(Chr(0))"
 
J

Jay B. Harlow [MVP - Outlook]

KSC,
I would recommend:

out = out.TrimEnd(" "c, Chr(0))

Hope this helps
Jay

| That was it Cor. Thank you.
|
| Changed line "out = out.TrimEnd(" "c)"
|
| to
|
| "out = out.TrimEnd(" "c).TrimEnd(Chr(0))"
|
|
|
| "Cor Ligthert [MVP]" wrote:
|
| > KSC.
| >
| > It can be that Out has a 00 character in it. Everything behind that is
not
| > showed.
| >
| > Just an idea
| >
| > Cor
| >
| >
| >
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top