473,800 Members | 2,529 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Directory.GetFi les question

Hi

When the routine below is run it gets to the line - Dim fileEntries As
String() = Directory.GetFi les(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.EventArg s) Handles InboxTimer.Tick
Try
Dim tString As String = gc.Inbox & "\"
Dim fileName As String = ""
InboxTimer.Enab led = False
Dim fileEntries As String() = Directory.GetFi les(tString)
For Each fileName In fileEntries
OpenInfile(file Name)
cf.Kill(fileNam e)
Next fileName
InboxTimer.Enab led = True
Catch ex As Exception
InboxTimer.Enab led = True
ErrorBox(ex.Mes sage)
End Try
End Sub
--

Kevin Martin
Motor Trade Technologies
--

Kevin Martin
Motor Trade Technologies
Nov 23 '05 #1
1 1767
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.Enab led = False

' Is the backslash necessary?
Dim tString As String = gc.Inbox & "\"
Dim fileEntries() As String = Directory.GetFi les(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(file Name)
cf.Kill(fileNam e)
Next
Catch ex As Exception
ErrorBox(ex.Mes sage)
Finally
' This will always run, whether an exception is thrown or not.
InboxTimer.Enab led = True
End Try

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

"Starbuck" <St******@tisco ni.com> wrote in message
news:Yq******** *********@newsf e1-gui.ntli.net...
Hi

When the routine below is run it gets to the line - Dim fileEntries As
String() = Directory.GetFi les(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.EventArg s) Handles InboxTimer.Tick
Try
Dim tString As String = gc.Inbox & "\"
Dim fileName As String = ""
InboxTimer.Enab led = False
Dim fileEntries As String() = Directory.GetFi les(tString)
For Each fileName In fileEntries
OpenInfile(file Name)
cf.Kill(fileNam e)
Next fileName
InboxTimer.Enab led = True
Catch ex As Exception
InboxTimer.Enab led = True
ErrorBox(ex.Mes sage)
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
30590
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 another way to enumerate files and subdirectories recursively which doesn't take too much memory in CS?
2
5981
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 does not work nor does something like this: string files = Directory.GetFiles(sDir, "*.doc, *.dot");
4
3713
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 Directory.GetFileSystemEntries(path), but I would like to know how to put this together, knowing which entry is a Subdirectory and which entry is a file, and make a recursive list of the Directory structure below a specific path - - -
2
1909
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 Directory.GetFiles("C:\TSA\DOWNLOADS\TRX\PERFORMANCE_DATA\DOWNLOAD\", "*1.TXT") Debug.WriteLine(filename) Next
2
1908
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 single filename, I could load it into a richedit control and do the parsing there but Directory.GetFiles doesn't seem to do what I want. Any tips on how to accomplisg this task?
3
4343
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. Any sugestions? Thanks, Michael.
3
4159
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 Directory.GetDirectories("C:\\")) { foreach (string f in Directory.GetFiles(d, "*.exe")) { MessageBox.Show(f); } }
3
2553
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 can copy, etc the file using the Windows XP explorer. I can trap the error, but then this traps the entire GetFiles() function, not just the one bad file. Is there a way to just trap for the one bad file and continue on?
0
1372
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, "GL*.*"); strFiles.CopyTo(Directory.GetFiles(SemaSettings.InputFilePath, "IN.*"),strFiles.Length-1); strFiles.CopyTo(Directory.GetFiles(SemaSettings.InputFilePath, "TX.*"),strFiles.Length-1,);
0
9690
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main usage, and What is the difference between ONU and Router. Let’s take a closer look ! Part I. Meaning of...
0
9551
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 effortlessly switch the default language on Windows 10 without reinstalling. I'll walk you through it. First, let's disable language synchronization. With a Microsoft account, language settings sync across devices. To prevent any complications,...
0
10274
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 tapestry of website design and digital marketing. It's not merely about having a website; it's about crafting an immersive digital experience that captivates audiences and drives business growth. The Art of Business Website Design Your website is...
1
10251
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 Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For most users, this new feature is actually very convenient. If you want to control the update process,...
0
10033
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 protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the choice of these technologies. I'm particularly interested in Zigbee because I've heard it does some...
0
6811
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 then checking html paragraph one by one. At the time of converting from word file to html my equations which are in the word document file was convert into image. Globals.ThisAddIn.Application.ActiveDocument.Select();...
0
5606
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
1
4149
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated we have to send another system
2
3764
muto222
by: muto222 | last post by:
How can i add a mobile payment intergratation into php mysql website.

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.