473,441 Members | 1,783 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,441 software developers and data experts.

Directory.GetFiles question

Hi

When the routine below is run it gets to the line - Dim fileEntries As
String() = Directory.GetFiles(tString) and then freezes, there is no errors
etc, the program just stops responding. The path is correct and does exist
and there is a test file in there
Any thoughts please?
Private Sub InboxTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles InboxTimer.Tick
Try
Dim tString As String = gc.Inbox & "\"
Dim fileName As String = ""
InboxTimer.Enabled = False
Dim fileEntries As String() = Directory.GetFiles(tString)
For Each fileName In fileEntries
OpenInfile(fileName)
cf.Kill(fileName)
Next fileName
InboxTimer.Enabled = True
Catch ex As Exception
InboxTimer.Enabled = True
ErrorBox(ex.Message)
End Try
End Sub
--

Kevin Martin
Motor Trade Technologies
--

Kevin Martin
Motor Trade Technologies
Nov 23 '05 #1
1 1744
CT
Kevin,

That works just fine here. Are you seeing the problem when run in Relwase
mode as well? In addition, is there only one file in the folder, and it is a
folder on a local drive? Which value have you assigned to the Interval
property of the timer control?

I modified your code slightly. I know it's a matter of preference, but I
think it looks a little cleaner (no offence ;-)):

Try
InboxTimer.Enabled = False

' Is the backslash necessary?
Dim tString As String = gc.Inbox & "\"
Dim fileEntries() As String = Directory.GetFiles(tString)

' No need to declare your temp string variable previously,
' unless you use it elsewhere outside the loop
For Each fileName As String In fileEntries
OpenInfile(fileName)
cf.Kill(fileName)
Next
Catch ex As Exception
ErrorBox(ex.Message)
Finally
' This will always run, whether an exception is thrown or not.
InboxTimer.Enabled = True
End Try

--
Carsten Thomsen
Communities - http://community.integratedsolutions.dk

"Starbuck" <St******@tisconi.com> wrote in message
news:Yq*****************@newsfe1-gui.ntli.net...
Hi

When the routine below is run it gets to the line - Dim fileEntries As
String() = Directory.GetFiles(tString) and then freezes, there is no
errors
etc, the program just stops responding. The path is correct and does exist
and there is a test file in there
Any thoughts please?
Private Sub InboxTimer_Tick(ByVal sender As System.Object, ByVal e As
System.EventArgs) Handles InboxTimer.Tick
Try
Dim tString As String = gc.Inbox & "\"
Dim fileName As String = ""
InboxTimer.Enabled = False
Dim fileEntries As String() = Directory.GetFiles(tString)
For Each fileName In fileEntries
OpenInfile(fileName)
cf.Kill(fileName)
Next fileName
InboxTimer.Enabled = True
Catch ex As Exception
InboxTimer.Enabled = True
ErrorBox(ex.Message)
End Try
End Sub
--

Kevin Martin
Motor Trade Technologies
--

Kevin Martin
Motor Trade Technologies

Nov 23 '05 #2

This thread has been closed and replies have been disabled. Please start a new discussion.

Similar topics

3
by: S. Han | last post by:
I'm using Directory.GetFiles to enumerate files in a directory. The problem is if you have to enumerate all files + subdirectories recursively, it takes too much memory, and it fails. Is there...
2
by: John Smith | last post by:
Hello all: I am trying to search for more than one extension in a directory at the same time with the following code: string files = Directory.GetFiles(sDir, "*.doc*.dot"); However, this...
4
by: Elmo Watson | last post by:
Is there a way, with the System.IO class, to do a recursive list of a directory structure? For instance, in DirectoryInfo, you have GetDirectories and GetFiles .... In Directory, you have...
2
by: OpticTygre | last post by:
I have a directory of 27 files. The files end in either 1.txt, 2.txt, 3.txt, or 4.txt. If I say: For Each filename As String In...
2
by: Xagon | last post by:
Hi, I'm a newbie to C#, so forgive me if this is a dumb question. What I want to do is parse a directory of IRC logfiles and dump all the .jpg and .gif links to a text file. If I could get a...
3
by: Michael | last post by:
Hi, I have been using Directory.GetFiles("g://"); in my c# application. But now my boss want's me to do Directory.GetFiles(IP address); I have been unable to figure out how to get this to work....
3
by: cjb | last post by:
Is there a way to get Directory.GetFiles to return multi-language file names? I haven't found any overloads that allow any such parameter. The way I am using it now is: foreach (string d in...
3
by: Michael Jackson | last post by:
In my .NET 2.0 VS 2005 VB application, I'm using Directory.GetFiles(path) to get all the files in the directory. However, I'm getting an error regarding "Illegal character in Path", even though I...
0
by: tshad | last post by:
I am trying to do multiple Directory.GetFiles and append the results to one array that I will process. I tried this: string strFiles; strFiles = Directory.GetFiles(SemaSettings.InputFilePath,...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.