|
From: Karl E. Peterson on 3 Jul 2008 14:06 expvb wrote: > Try one of the following to see which one works: > > 1 - Specify a path that can not possibly exist, such as a long file name > with random characters. Internally, FindFirstFile should not find a first > file. > > 2 - Specify a path that contains invalid characters. > > 3 - From the Remarks section of FindFirstFile, "An attempt to open a search > with a trailing backslash will always fail.", so using "C:\" will always > fail. Normally "C:\*" should be used in that case to search the root of the > C: drive. Which "works"? In what way? Not sure what goal you're after, here? -- ..NET: It's About Trust! http://vfred.mvps.org
From: Karl E. Peterson on 3 Jul 2008 14:09 PeterD wrote: > In Dir("nul") you (probably) don't have a folder named "nul" so the > dir command completes, and frees its handle? Like Tony said, it's impossible. But you can use "nul" to test for directory existance. Ex: Exists = Len(Dir("c:\windows\nul")) > 0 > I think you will find the > same is true when the Dir() is called (no parameter) sufficiently to > enumerate all the items in the given folder based on the first call > that creates the handle. I need to test that. It makes sense. -- ..NET: It's About Trust! http://vfred.mvps.org
From: Karl E. Peterson on 3 Jul 2008 14:12 expvb wrote: > I just tested various combinations using a compiled VB6+SP5 app on XP+SP2, > and the result is below. I did these one by one and recompiled each time: > > These released the previous Dir handle. The first is a non existing file or > folder. None of these statements generated a run time error: > > Debug.Print Dir("skldjfhlksdfhkasjdlfkaslkdjasjkdlaskdl") > Debug.Print Dir(";") > Debug.Print Dir(Chr(34)) > Debug.Print Dir("<") > Debug.Print Dir(">") > Debug.Print Dir("nul") > > These did not release the previous Dir handle. None of these statements > generated a run time error: > > Debug.Print Dir("") > Debug.Print Dir("\") > Debug.Print Dir("C:\") > Debug.Print Dir(vbNullString) Cool pattern! It's going unsaid, but I'm taking it folks are using TaskMgr to watch the handle count for these tests? Is there anyway to do this from code, so as to automate tests like the above? > The following generated a run time error 52: Bad file name or number. > > Debug.Print Dir("|") Intriguing! Especially given the behavior with the other redirection symbols. -- ..NET: It's About Trust! http://vfred.mvps.org
From: Karl E. Peterson on 3 Jul 2008 19:48 Larry Serflaten wrote: > "Karl E. Peterson" <karl(a)mvps.org> wrote >> PeterD wrote: >> > In Dir("nul") you (probably) don't have a folder named "nul" so the >> > dir command completes, and frees its handle? >> >> Like Tony said, it's impossible. > > Its not impossible, only difficult. The image below shows an > actual listing on my W2K system... You must've cheated?! <g> Got a space in there, or something? -- ..NET: It's About Trust! http://vfred.mvps.org
From: Larry Serflaten on 3 Jul 2008 20:26 "Karl E. Peterson" <karl(a)mvps.org> wrote > > Its not impossible, only difficult. The image below shows an > > actual listing on my W2K system... > > You must've cheated?! <g> Got a space in there, or something? Yes, in effect I cheated, I simply renamed an already existing folder to NUL using the technique at the bottom of the Naming a File page. (preceeded full path with \\.\) Ref: http://msdn.microsoft.com/en-us/library/aa365247.aspx I could not delete the folder, (tried it to see if I could) and had to rename it again to delete. LFS
First
|
Prev
|
Next
|
Last
Pages: 1 2 3 4 5 Prev: No license to use this functionality Next: XML displays in console but not in text boxes |