XP explorer says file is there - my app says 'File not found'

XP explorer says file is there - my app says 'File not found'

Post by newspos » Fri, 28 Nov 2008 19:49:37


This is only happening on one users machine and I'm really running out
of ideas. My app seems to refuse to recognise filenames that are
clearly in the correct folder and can be seen in a directory listing.
I can't help feeling this has got something to do with mixed case
filenames - but I'm not sure what - does XP have a setting that might
make this a problem?

A bit desparate :O(

Marshal
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by VB M » Fri, 28 Nov 2008 20:06:01


XXXX@XXXXX.COM (Marshal Anderson)'s wild
thoughts were released on Thu, 27 Nov 2008 10:49:37 GMT
bearing the following fruit:


Might help if you show us the code you are using.
https://mvp.support.microsoft.com/profile/Jan.Hyde

 
 
 

XP explorer says file is there - my app says 'File not found'

Post by newspos » Fri, 28 Nov 2008 20:26:18

On Thu, 27 Nov 2008 10:49:37 GMT, XXXX@XXXXX.COM




Bizzar development - I've accidentally recreated EXACTLY the same
error while putting in some debugging forms. If I include the line:

frmdebug_directory.dir_debug.Path = BasePath & "\TTstartUp.tts"

it not only generates the same error - I suppose it would as it's got
a file name at the end, but it created the same subsiquesnt not found
errors :-/
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Norm Coo » Fri, 28 Nov 2008 22:15:32


You did not say what 'BasePath' contains. If it has a
trailing backslash (\) that might be the source of your error.

These might be helpful:

Private Function QualifyPath(ByVal sPath As String) As String
If Right$(sPath, 1) <> "\" Then
QualifyPath = sPath & "\"
Else
QualifyPath = sPath
End If
End Function
Private Function UnQualifyPath(ByVal sPath As String) As String
If Right$(sPath, 1) = "\" Then
QualifyPath = Left$(sPath, Len(sPath) - 1)
Else
QualifyPath = sPath
End If
End Function
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by BeastFis » Sat, 29 Nov 2008 02:55:41

Some thoughts off the top of my head...

Any chance the file is hidden? Does a GetAttr throw an error?

As Norm pointed out, is the path OK (all backslash "ducks in order", etc.)?

Does the file reside in a "regular" directory (like "C:\TheFolder\") or a
shell folder (like "My Documents")? If the latter, are you certain you are
retrieving its "real" name with the correct CSIDL? See the following:
http://www.yqcomputer.com/
http://www.yqcomputer.com/
http://www.yqcomputer.com/

What happens if you use GetShortPathName? (Sample from AllAPI.net API-Guide
found at http://www.yqcomputer.com/ )...

Private Declare Function GetShortPathName Lib "kernel32" _
Alias "GetShortPathNameA" (ByVal lpszLongPath As String, _
ByVal lpszShortPath As String, ByVal lBuffer As Long) _
As Long
Private Function GetShortPath(strFileName As String) As String
'KPD-Team 1999
'URL: http://www.yqcomputer.com/
Dim lngRes As Long, strPath As String
'Create a buffer
strPath = String$(165, 0)
'retrieve the short pathname
lngRes = GetShortPathName(strFileName, strPath, 164)
'remove all unnecessary chr$(0)'s
GetShortPath = Left$(strPath, lngRes)
End Function
Private Sub Form_Load()
MsgBox GetShortPath(WhateverPathAndFile)
End Sub
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Randy Birc » Sat, 29 Nov 2008 04:00:51

Betcha you have two \\ in the path - check the values of all the variables
right before the file access attempt.

--

Randy Birch
ms mvp - visual basic
http://www.yqcomputer.com/
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Randy Birc » Sat, 29 Nov 2008 04:01:08

Betcha you have two \\ in the path - check the values of all the variables
right before the file access attempt.

--

Randy Birch
ms mvp - visual basic
http://www.yqcomputer.com/
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by newspos » Tue, 30 Dec 2008 23:17:34

Just to say I know it isn't that coz I have a routine that checks all
assembled path names for double slashes. But I bet it will be a good
idea to check that works ;o)

Marshal

On Thu, 27 Nov 2008 14:00:51 -0500, "Randy Birch"
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by newspos » Tue, 30 Dec 2008 23:21:33

Thanks for these Norm - I already check from duplicate slashes, but
maybe an additional slash has got in there. Thing is, this app have
been running for years with over a thousand different users and this
is the first time it's happened :O(

Marshal

On Thu, 27 Nov 2008 07:15:32 -0600, "Norm Cook"
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Peter B. S » Wed, 31 Dec 2008 02:18:47

On Mon, 29 Dec 2008 14:21:33 +0000, Marshal Anderson sez:


Pop up a MsgBox() showing the exact path/file that it is checking for, to
confirm that the name is indeed correct.

Having said that, I hope you're smarter than I am about remembering to
remove diagnostic messages before the final release. More than once I've
had a client tell me "it works fine, but why does it pop up a message
window saying 'Hi, I made it to line 32 of Xyzzy' every time I click on
the grue icon?"

--
Peter B. Steiger
Cheyenne, WY
If you must reply by email, you can reach me by placing
zeroes where you see stars: wypbs.**1 at gmail.com
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Larry Serf » Wed, 31 Dec 2008 04:32:51


"Peter B. Steiger" < XXXX@XXXXX.COM > wrote



For Pete's sake man! Put something like the following into a class, and
use that to pop up your messages. You can get more detailed with the
parameters if you want, but it will help you avoid that situation letting you
determine if you want messages while in the IDE, or EXE, or both....

To use it declare a public variable somewhere and put it to use....

Public zzz As New DebugMsgs
...
zzz.Post "Finished line 32 of " & ProcName

LFS

' --- DebugMsgs class
Option Explicit

Public Enum zUsageMode
UnKnown = -1
IDE = 1
EXE = 2
Both = 3
End Enum

Private IDEMode As Boolean

Public Sub Post(Msg As String, Optional Mode As zUsageMode = IDE)
Select Case Mode
Case zUsageMode.IDE, zUsageMode.Both
If IDEMode Then MsgBox Msg
Case zUsageMode.EXE, zUsageMode.Both
MsgBox Msg
End Select
End Sub

Private Sub Class_Initialize()
Debug.Assert SetIDE
End Sub

Private Function SetIDE() As Boolean
SetIDE = True
IDEMode = True
End Function
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by expv » Wed, 31 Dec 2008 05:05:45


Here is a similar declaration I use, which can be used as a drop in
replacement for MsgBox:

Public Sub DebugMsgBox(Prompt As String, _
Optional ByVal Buttons As VbMsgBoxStyle = vbOKOnly, _
Optional ByVal Title As String = "")

Also, for Peter, MZTools Find dialog has "Exclude Comments", which you can
use to easily find the remaining MsgBox and Debug.Print that you haven't
commented out. The text that you specify in Debug.Print gets compiled in the
EXE, and would be searchable using a hex editor.
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Larry Serf » Wed, 31 Dec 2008 05:53:40


"expvb" < XXXX@XXXXX.COM > wrote


The main point in all this is that you replace the MsgBox command
with something else. That allows it to be used for those cases that
you absolutely want shown in the EXE.

With a unique name for debug messages a simple search and replace
will comment out all those special purpose messages without getting
confused with MsgBox calls you want to include in the EXE.

LFS
 
 
 

XP explorer says file is there - my app says 'File not found'

Post by Bill McCar » Wed, 31 Dec 2008 09:57:45


Searching and replacing, actually modifying your source code just to do a
release build is counter productive. IF the goal is to have it that the
strings are not in the exe, then compiler directives gives you that:

#Const IsDebug = True


then elsewhere ...

#If IsDebug Then
MsgBox "some string I don't want in the final exe"
#End If

you then simply toggle the IsDebug constant to true or false.