BSoD using DirectoryInfo.Create() or FileInfo.MoveTo() in Console Application

  • Thread starter Thread starter Boogum.com
  • Start date Start date
B

Boogum.com

All--

I've written a small console application to replace an old DOS batch
file that periodically takes all of the files out of a source
directory and breaks them up into a number of subdirectories in a
target directory. (The purpose of this application and the DOS batch
file before it is to keep a directory on an FTP server from filling up
with more files than it can handle.)

For some reason, I get a bluescreen whenever I run this application on
any directory with more than a few hundred files. Here is the section
of the code I believe is the most likely source of this error:

For iter = 0 To iTotalFileCount - 1
If iter Mod iFileCount = 0 Then
Do

iSubDirCount += 1
diThisSubDirectory = New
DirectoryInfo(diTarget.FullName & "\" & _
iSubDirCount.ToString("00000"))
Loop While diThisSubDirectory.Exists()
If diTarget.GetDirectories.GetUpperBound(0) +
1 >= 32767 Then
Console.WriteLine("Target directory full.
Operation aborted.")
Return
Else

Console.WriteLine("Creating " &
diThisSubDirectory.FullName)
diThisSubDirectory.Create()
'diThisSubDirectory.Refresh()
End If
End If

flSource(iter).MoveTo(diThisSubDirectory.FullName() & "\" &
flSource(iter).Name())
'flSource(iter).Refresh()
'diThisSubDirectory.Refresh()
Next

Has anyone seen this behavior before? I've run the code both with and
without the .Refresh() calls you see that are commented out.

TIA for any light y'all can shed on this error.

--Jekke
==
To e-mail me, deobfuscate jekkeATinsidejokeDOTtv.
 
Hi Boogum,

I write a test sample and can not reproduce the problem.
Here is my code.

'----------------------------------code
begin------------------------------------------------------------------
Imports System
Imports System.IO
Module Module1
Sub Main()
Dim iter, iTotalFileCount, iSubDirCount As Integer
iTotalFileCount = 500
'===============Create test file====================================
Dim sw As StreamWriter
Dim i As Integer
For i = 1 To iTotalFileCount
sw = New StreamWriter("D:\temp\" + i.ToString("00000") + ".txt")
sw.WriteLine(Now.ToString() + i.ToString("00000"))
sw.Close()
Next
'===============Create test file====================================
'Create directory and move files
Dim diThisSubDirectory As DirectoryInfo
Dim src, des As String
For iter = 1 To iTotalFileCount
Try
diThisSubDirectory = New DirectoryInfo("C:\temp\A" +
iter.ToString("00000"))
diThisSubDirectory.Create()
src = "D:\temp\" + iter.ToString("00000") + ".txt"
des = diThisSubDirectory.FullName + "\" +
iter.ToString("00000") + ".txt"
File.Move(src, des)
Console.WriteLine("Move File " + src + " To" + des + "
Successful")
Catch e As Exception
Console.WriteLine(e.ToString)
End Try
Next
End Sub
End Module
'----------------------------------code
end---------------------------------------------------------------------

To troubleshoot the problem, you may try to use the try-catch to handle the
exception.
Since you will encounter blue screen, you may try to write some log into
disk file.
So that when you get blue screen, you can scan the log file to locate what
cause the blue screen.
You may try to log the time, calling method and the current move file and
directory.

If you have any concern on this issue, please post here.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Boogum.com said:
For some reason, I get a bluescreen whenever I run this application
on any directory with more than a few hundred files. Here is the
section of the code I believe is the most likely source of this
error:

The bluescreen doesn't give more information on the error?


Often recommended: http://www.memtest86.com/
 
The bluescreen doesn't give more information on the error?

Just a cryptic hex-based error code and a cryptic hex-based memory
address.

It looks like I'm going to have to do more testing. I'll make note of
any additional error information.

--Jekke
==
To e-mail me, deobfuscate jekkeATinsidejokeDOTtv.
 
The bluescreen doesn't give more information on the error?

Here's the bluescreen information:

*** STOP 0x000000C2 (0x00000099m, 0xE134B008, 0x00000000, 0x00000000)
BAD_POOL_CALLER

This means nothing to me. Does it mean anything to you?

--Jekke
==
To e-mail me, deobfuscate jekkeATinsidejokeDOTtv.
 
Hi Boogum,

Did you try my test code in my last post?
This will help us to isolate the problem, I will appreciate your efforts.

Regards,
Peter Huang
Microsoft Online Partner Support
Get Secure! www.microsoft.com/security
This posting is provided "as is" with no warranties and confers no rights.
 
Back
Top