Click here to Skip to main content
15,908,901 members
Home / Discussions / C#
   

C#

 
GeneralDisposing resources used by MD5CryptoServiceProvider Pin
sillypuppy21-Nov-04 2:52
sillypuppy21-Nov-04 2:52 
Hello all Big Grin | :-D

I have this problem with managing resources. I am writing a cataloging application in which i need to compute a MD5 hash value for each file in the tree structure given a directory. This is done recursively. Now until I have added a function to compute the hash everything was working smoothely however now the application freezes.
This could be because i do not have enough free resources. I tried calling a Dispose method of the MD5CryptoServiceProvier but it is protected therefore not allowed to be accessed.
IS Garbage Collector an option? If so where should it be applied.

To give you an idea. The function ComputeHash looks the following:

private string ComputeDigest(FileInfo file)<br />
{	<br />
  MD5CryptoServiceProvider csp = new MD5CryptoServiceProvider();<br />
  FileStream fstream;<br />
  try<br />
  {<br />
	fstream = File.OpenRead(file.FullName);<br />
  }<br />
  catch(Exception e)<br />
  {<br />
  MessageBox.Show("Error Occured: " + e.Message);<br />
  return null;<br />
  }<br />
  byte [] hash = csp.ComputeHash(fstream);<br />
  fstream.Close();<br />
  string hash_string = String.Copy(BitConverter.ToString(hash));<br />
  csp.Clear();<br />
  return hash_string;<br />
}


Izabela
GeneralPorting C++ struct to C# (BladeEnc.dll) Pin
Pr1v21-Nov-04 1:44
Pr1v21-Nov-04 1:44 
QuestionHow Can I Draw lines and text in DataGrid Header Pin
Hamada_star20-Nov-04 22:46
Hamada_star20-Nov-04 22:46 
AnswerRe: How Can I Draw lines and text in DataGrid Header Pin
sreejith ss nair21-Nov-04 16:59
sreejith ss nair21-Nov-04 16:59 
Generalprinting Pin
20-Nov-04 20:51
suss20-Nov-04 20:51 
GeneralRe: printing Pin
Luis Alonso Ramos20-Nov-04 21:26
Luis Alonso Ramos20-Nov-04 21:26 
GeneralRe: printing Pin
sreejith ss nair21-Nov-04 17:07
sreejith ss nair21-Nov-04 17:07 
GeneralCOM+ Transaction and server farms/database clustering Pin
devvvy20-Nov-04 19:10
devvvy20-Nov-04 19:10 
Generalcopying textbox value to another textbox Pin
Member 144657320-Nov-04 18:10
Member 144657320-Nov-04 18:10 
GeneralRe: copying textbox value to another textbox Pin
sreejith ss nair20-Nov-04 18:35
sreejith ss nair20-Nov-04 18:35 
GeneralRe: copying textbox value to another textbox Pin
Charlie Williams20-Nov-04 20:15
Charlie Williams20-Nov-04 20:15 
GeneralRe: copying textbox value to another textbox Pin
Dave Kreskowiak22-Nov-04 4:17
mveDave Kreskowiak22-Nov-04 4:17 
GeneralRe: copying textbox value to another textbox Pin
Charlie Williams20-Nov-04 20:24
Charlie Williams20-Nov-04 20:24 
GeneralRe: copying textbox value to another textbox Pin
Member 144657320-Nov-04 20:50
Member 144657320-Nov-04 20:50 
GeneralClass accesability and namespaces Pin
aspiringCodeMonkey20-Nov-04 17:05
aspiringCodeMonkey20-Nov-04 17:05 
GeneralRe: Class accesability and namespaces Pin
sreejith ss nair20-Nov-04 19:17
sreejith ss nair20-Nov-04 19:17 
GeneralRe: Class accesability and namespaces Pin
Andrew C Armstrong21-Nov-04 11:54
Andrew C Armstrong21-Nov-04 11:54 
GeneralDIVIDE APPLICATION TO FRAMES Pin
binary_c220-Nov-04 16:52
binary_c220-Nov-04 16:52 
GeneralRe: DIVIDE APPLICATION TO FRAMES Pin
Luis Alonso Ramos20-Nov-04 21:30
Luis Alonso Ramos20-Nov-04 21:30 
GeneralCustom Control Property Pin
pjholliday20-Nov-04 10:51
pjholliday20-Nov-04 10:51 
GeneralRe: Custom Control Property Pin
sreejith ss nair20-Nov-04 18:47
sreejith ss nair20-Nov-04 18:47 
Generalupdating a form while in a loop Pin
Anonymous20-Nov-04 6:56
Anonymous20-Nov-04 6:56 
GeneralRe: updating a form while in a loop Pin
Pauwll20-Nov-04 7:21
Pauwll20-Nov-04 7:21 
GeneralRe: updating a form while in a loop Pin
Anonymous21-Nov-04 4:04
Anonymous21-Nov-04 4:04 
GeneralRe: updating a form while in a loop Pin
Sebastian Schneider21-Nov-04 23:29
Sebastian Schneider21-Nov-04 23:29 

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.