Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array.
Can't open a path from an array. Can't open a path from an array.
Can't open a path from an array.
Go Back  Xtreme Visual Basic Talk > > > Can't open a path from an array.


Reply
 
Thread Tools Display Modes
  #1  
Old 02-12-2016, 04:00 PM
MAW MAW is offline
Newcomer
 
Join Date: Feb 2004
Location: UK
Posts: 22
Default Can't open a path from an array.


Hi,

I have an unusual annoying problem; I have a function that gathers a list of files from a remote location (At the moment it's just one) and puts each path in an array and in turn goes on to open each one:

Code:
For i = 0 To UBound(Profiles)
    RawData = Space$(16)
    Open Profiles(i) For Binary As #1
        Get #1, , RawData
Quote:
Profiles(i)
being the array.

The issue I'm having is that the return location is '\\Remote_Drive\Public\Data\Ls2LQKOJ.pfe' and I get an error 52: Bad file name or number. BUT if I just quote the path directly it works fine.

Any ideas?
Reply With Quote
  #2  
Old 02-13-2016, 12:46 AM
dilettante's Avatar
dilettanteCan't open a path from an array. dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

Examine the contents of an array element carefully, there must be something different about it.

If you can't see it then test it, e.g.:

Code:
If Profiles(0) = "\\Remote_Drive\Public\Data\Ls2LQKOJ.pfe" Then
    MsgBox "Same"
Else
    MsgBox "Different"
End If
Reply With Quote
  #3  
Old 02-13-2016, 04:58 AM
MAW MAW is offline
Newcomer
 
Join Date: Feb 2004
Location: UK
Posts: 22
Default

Well this is about the weirdest problem I've ever encountered in VB.

I tried;
Code:
If Dir(tmpProfiles(i), vbArchive) <> "" Then MsgBox "File exists"
(Also without the archive) and it doesn't seem to SEE it, but again when I quote the path directly it opens it. I used debug.print to extract the path in the array and compared it visually and it's exactly the same, then compared it in VB and it's somehow NOT the same. I don't understand what's going on at all here.
Reply With Quote
  #4  
Old 02-13-2016, 05:18 AM
MAW MAW is offline
Newcomer
 
Join Date: Feb 2004
Location: UK
Posts: 22
Default

EDIT: after more testing, even though the paths are EXACTLY the same, no matter what I do it simply doesn't see the file unless I quote the path directly, though weirdly always gives the same 'Bad file or number' error and not 'Path/file access' error. I've never encountered anything like this before, lol.

Another note is that if I quote the path INTO a string, then it opens it too, and just like if I do that THEN compare the array and the quoted string - even though they're exactly the same, they don't match. Just gets weirder.
Reply With Quote
  #5  
Old 02-13-2016, 11:56 AM
dilettante's Avatar
dilettanteCan't open a path from an array. dilettante is offline
Underclocked lifestyle

Forum Leader
* Guru *
 
Join Date: Feb 2005
Location: Michigan, USA
Posts: 4,524
Default

The non-working String values might contain NUL or other characters you don't see. Could even be Unicode characters that look like normal characters after translating to ANSI for display.

You'd probably need a hex dump of the actual String to see the problem.
Reply With Quote
  #6  
Old 02-16-2016, 01:44 AM
fafalone fafalone is offline
Freshman
 
Join Date: May 2010
Posts: 37
Default

Having encountered just such an issue before I have such a function handy:
Code:
Public Sub dbg_stringdump(s As String)
Dim i As Long
Dim z As String
For i = 1 To Len(s)
    z = z & AscW(Mid(s, i, 1)) & " "
Next i
Debug.Print "StringDump(" & s & ")=" & z
End Sub
Reply With Quote
Reply

Tags
array, path


Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
 
Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off

Forum Jump

Advertisement:





Free Publications
The ASP.NET 2.0 Anthology
101 Essential Tips, Tricks & Hacks - Free 156 Page Preview. Learn the most practical features and best approaches for ASP.NET.
subscribe
Programmers Heaven C# School Book -Free 338 Page eBook
The Programmers Heaven C# School book covers the .NET framework and the C# language.
subscribe
Build Your Own ASP.NET 3.5 Web Site Using C# & VB, 3rd Edition - Free 219 Page Preview!
This comprehensive step-by-step guide will help get your database-driven ASP.NET web site up and running in no time..
subscribe
Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array. Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array. Can't open a path from an array.
Can't open a path from an array.
Can't open a path from an array.
 
Can't open a path from an array.
Can't open a path from an array.
 
-->