Click here to Skip to main content
16,008,719 members
Home / Discussions / .NET (Core and Framework)
   

.NET (Core and Framework)

 
QuestionControlling the focus in WindowsForms Pin
Dobromir Dimitrov21-Nov-06 23:31
Dobromir Dimitrov21-Nov-06 23:31 
QuestionList of forms in project Pin
Rudi Groenewald21-Nov-06 19:01
Rudi Groenewald21-Nov-06 19:01 
AnswerRe: List of forms in project Pin
Ed.Poore22-Nov-06 3:59
Ed.Poore22-Nov-06 3:59 
QuestionDirectoryInfo.GetDirectories exception Pin
CPP_Student21-Nov-06 14:44
CPP_Student21-Nov-06 14:44 
AnswerRe: DirectoryInfo.GetDirectories exception Pin
Ed.Poore22-Nov-06 4:03
Ed.Poore22-Nov-06 4:03 
GeneralRe: DirectoryInfo.GetDirectories exception Pin
CPP_Student22-Nov-06 11:45
CPP_Student22-Nov-06 11:45 
GeneralRe: DirectoryInfo.GetDirectories exception Pin
Ed.Poore22-Nov-06 12:24
Ed.Poore22-Nov-06 12:24 
GeneralRe: DirectoryInfo.GetDirectories exception Pin
CPP_Student22-Nov-06 12:45
CPP_Student22-Nov-06 12:45 
The GetDirectories() function returns an array of DirectoryInfo's, not strings. Besides, your code won't work either, since you have the foreach statement outside of the try block. It is on the foreach that it gets the exception. I just decided to pull the code out of the foreach statement so I could better figure out where it was getting the exception. So, I have this:

static void FindFile(DirectoryInfo dirInfo, string fileName, out FileInfo fileFound)<br />
		{<br />
			try<br />
			{<br />
				DirectoryInfo[] dirs = dirInfo.GetDirectories("*.*", SearchOption.AllDirectories);<br />
				foreach (DirectoryInfo di in dirs)<br />
				{<br />
					if ((di.Attributes & FileAttributes.System) == 0)<br />
					{<br />
						FileInfo fileI = SearchDirectory(di, fileName);<br />
						if (fileI != null)<br />
						{<br />
							fileFound = fileI;<br />
							return;<br />
						}<br />
					}<br />
				}<br />
			}<br />
			catch (System.UnauthorizedAccessException ex)<br />
			{<br />
				Console.WriteLine("Security EXCEPTION: {0}", ex.Message);<br />
				fileFound = null;<br />
				return;<br />
			}<br />
<br />
			catch (Exception ex)<br />
			{<br />
				Console.WriteLine("EXCEPTION: {0}", ex.ToString());<br />
				fileFound = null;<br />
				return;<br />
			}<br />
			fileFound = null;<br />
		}


It bombs on the first instruction (GetDirectories). Thkx
GeneralRe: DirectoryInfo.GetDirectories exception Pin
Ed.Poore22-Nov-06 13:21
Ed.Poore22-Nov-06 13:21 
GeneralRe: DirectoryInfo.GetDirectories exception Pin
CPP_Student22-Nov-06 13:50
CPP_Student22-Nov-06 13:50 
Questiontextbox multi line Pin
biaali21-Nov-06 6:57
biaali21-Nov-06 6:57 
AnswerRe: textbox multi line Pin
Leah_Garrett21-Nov-06 16:39
Leah_Garrett21-Nov-06 16:39 
GeneralRe: textbox multi line Pin
biaali23-Nov-06 0:08
biaali23-Nov-06 0:08 
QuestionDatagrid in vc++.net Pin
haritha2221-Nov-06 6:51
haritha2221-Nov-06 6:51 
AnswerRe: Datagrid in vc++.net Pin
Paul Conrad25-Dec-06 18:43
professionalPaul Conrad25-Dec-06 18:43 
QuestionHow to generate dynamically proxy for some classes ? Pin
vgrigor121-Nov-06 3:20
vgrigor121-Nov-06 3:20 
GeneralFIX: An application that is based on the .NET Framework 2.0 may crash unexpectedly Pin
Leftyfarrell21-Nov-06 2:48
Leftyfarrell21-Nov-06 2:48 
GeneralRe: FIX: An application that is based on the .NET Framework 2.0 may crash unexpectedly Pin
Kevin McFarlane21-Nov-06 23:49
Kevin McFarlane21-Nov-06 23:49 
Questionthe server returned an invalid or unrecognized response Pin
radixpune21-Nov-06 2:12
radixpune21-Nov-06 2:12 
AnswerRe: the server returned an invalid or unrecognized response Pin
Paul Conrad27-Dec-06 18:03
professionalPaul Conrad27-Dec-06 18:03 
QuestionSmart Device Application in VS 2005 Pin
Irs_ahmad20-Nov-06 20:54
Irs_ahmad20-Nov-06 20:54 
Questionflash proble since last two month Pin
Tauseef A20-Nov-06 18:43
Tauseef A20-Nov-06 18:43 
AnswerRe: flash proble since last two month Pin
Kastellanos Nikos29-Nov-06 3:25
Kastellanos Nikos29-Nov-06 3:25 
QuestionHow can I extract icon from DLL or EXE file ? Pin
Glen Liu20-Nov-06 12:43
Glen Liu20-Nov-06 12:43 
AnswerRe: How can I extract icon from DLL or EXE file ? Pin
Luc Pattyn21-Nov-06 4:43
sitebuilderLuc Pattyn21-Nov-06 4:43 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.