Click here to Skip to main content
15,913,027 members
Home / Discussions / C#
   

C#

 
GeneralSimple Question: COM interop Pin
CillyMe13-Nov-03 17:15
CillyMe13-Nov-03 17:15 
GeneralRe: Simple Question: COM interop Pin
Heath Stewart14-Nov-03 2:29
protectorHeath Stewart14-Nov-03 2:29 
Generalresizing controls Pin
udaan200313-Nov-03 13:16
udaan200313-Nov-03 13:16 
GeneralRe: resizing controls Pin
Heath Stewart14-Nov-03 2:41
protectorHeath Stewart14-Nov-03 2:41 
GeneralRe: resizing controls Pin
udaan200314-Nov-03 4:24
udaan200314-Nov-03 4:24 
GeneralRe: resizing controls Pin
Heath Stewart14-Nov-03 4:31
protectorHeath Stewart14-Nov-03 4:31 
Generalreleasing System.IO.FileInfo Pin
assinine13-Nov-03 11:35
assinine13-Nov-03 11:35 
GeneralRe: releasing System.IO.FileInfo Pin
Heath Stewart14-Nov-03 2:35
protectorHeath Stewart14-Nov-03 2:35 
You could set all FileInfo references to null. The GC will clean them up when it wants to, or you could force it with GC.Collect (although this isn't recommend).

A warning / piece of advice: FileInfo doesn't actually open the file, though it has methods that will create certain types of streams for you. What is most likely the problem is that you're not closing the streams elsewhere. Below is a piece of code that is recommend and best to use when possible:
Stream s = null;
try
{
  s = new FileStream(...);
  // Do something with the stream.
}
catch (Exception e) // Optional if error handling desired
{
  Trace.WriteLine(e.Message);
}
finally
{
  if (s != null) s.Close(); (// May want to flush the appropriate stream, too.
}
The finally block gets called no matter if the stream operations succeed or fail. Closing the stream frees the file system handle (FILE) to the file. Not closing the stream will most commonly lead to the problems you are getting.

 

-----BEGIN GEEK CODE BLOCK-----
Version: 3.21
GCS/G/MU d- s: a- C++++ UL@ P++(+++) L+(--) E--- W+++ N++ o+ K? w++++ O- M(+) V? PS-- PE Y++ PGP++ t++@ 5 X+++ R+@ tv+ b(-)>b++ DI++++ D+ G e++>+++ h---* r+++ y+++
-----END GEEK CODE BLOCK-----
GeneralToolbar Component Setting Pin
zuhx13-Nov-03 11:08
zuhx13-Nov-03 11:08 
GeneralRe: Toolbar Component Setting Pin
Heath Stewart14-Nov-03 2:37
protectorHeath Stewart14-Nov-03 2:37 
Generalhandling a voice event Pin
eafares26513-Nov-03 10:15
eafares26513-Nov-03 10:15 
GeneralRe: handling a voice event Pin
Kentamanos13-Nov-03 10:47
Kentamanos13-Nov-03 10:47 
GeneralRe: handling a voice event Pin
eafares26514-Nov-03 5:03
eafares26514-Nov-03 5:03 
GeneralBlock scope when using 'using' statement. Pin
Bill Priess13-Nov-03 6:29
Bill Priess13-Nov-03 6:29 
GeneralRe: Block scope when using 'using' statement. Pin
Heath Stewart13-Nov-03 7:06
protectorHeath Stewart13-Nov-03 7:06 
GeneralRe: Block scope when using 'using' statement. Pin
Bill Priess13-Nov-03 7:34
Bill Priess13-Nov-03 7:34 
GeneralRe: Block scope when using 'using' statement. Pin
Heath Stewart13-Nov-03 8:42
protectorHeath Stewart13-Nov-03 8:42 
GeneralRe: Block scope when using 'using' statement. Pin
Bill Priess13-Nov-03 9:54
Bill Priess13-Nov-03 9:54 
Generaldotnetmagic concepts Pin
mikemilano13-Nov-03 6:13
mikemilano13-Nov-03 6:13 
GeneralRe: dotnetmagic concepts Pin
Heath Stewart13-Nov-03 6:49
protectorHeath Stewart13-Nov-03 6:49 
GeneralCompiler error Pin
Jose Vicente13-Nov-03 5:16
Jose Vicente13-Nov-03 5:16 
GeneralRe: Compiler error Pin
Heath Stewart13-Nov-03 6:40
protectorHeath Stewart13-Nov-03 6:40 
GeneralRe: Compiler error Pin
Jose Vicente13-Nov-03 20:39
Jose Vicente13-Nov-03 20:39 
GeneralRe: Compiler error Pin
Heath Stewart14-Nov-03 1:59
protectorHeath Stewart14-Nov-03 1:59 
GeneralSimple question: PerformanceCounter Pin
CillyMe13-Nov-03 4:27
CillyMe13-Nov-03 4:27 

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.