TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Chad Mancl
NA
11
0
System.StackOverFlow Exception...
Apr 12 2008 3:05 AM
Hello...
I have an application that simply loops through all files in a given path and reports the number back on the form in a label.
I created a application that only does this function and here is the code...
//Form Code...
public partial class Form1 : Form
{
public int iFilesFound = 0;
public Form1()
{
InitializeComponent();
}
public void UpdateFileCounterLabel(int iCtr)
{
//I get the error on any of these lines....
this.iFilesFound = iCtr;
this.lblFileCtr.Text = "| " + Convert.ToString(iFilesFound) + " File(s) Found |";
Application.DoEvents();
}
private void button1_Click(object sender, EventArgs e)
{
clsLoop.GetFileCount();
MessageBox.Show("Done");
}
}
//Seperate Class...
class clsLoop
{
public static int i = 0;
public static void GetFileCount()
{
string[] strFolders = System.IO.Directory.GetDirectories(@"C:\");
string[] strFiles = System.IO.Directory.GetFiles(@"C:\");
foreach (string strFile in strFiles)
{
i++;
Form1 f = (Form1)Application.OpenForms["Form1"];
f.UpdateFileCounterLabel(i);
}
foreach (string strFolder in strFolders)
{
FileAttributes attributes = File.GetAttributes(strFolder);
if ((attributes & FileAttributes.Hidden) != FileAttributes.Hidden)
{
GetFileCount();
}
}
}
}
I have been unable to catch this exception and from what I read I cannot catch it. It appears to crash around 85,000 files found. (This is just a small part of a bigger application where I need to know how many files are in the selected directory so I can calculate processing time and percetage completed).
Thanks For All Your Help In Advance...
Chad
Reply
Answers (
1
)
Share a SQL DB connection in the same form
generating reports onPDF format for the source being XML file