Results 1 to 12 of 12

Thread: File in use Exception

  1. #1

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913

    File in use Exception

    Maybe I dont see it or i m missing something, but is there a non generic IOException that covers file in use, or perhaps some other type of Exception? As far as I can tell, no, but wanted to see if I missed it.

    Right now I am using Catch FileinUse As IOException, but its best to use specific ones if they exist.

    Anyone?
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  2. #2
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    Which object are you using? The StreamWriter throws an UnauthorizedAccessException when access is denied to a file.

  3. #3

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Sorry forgot. I m using the Stream object

    Dim openfile As Stream = File.Open(blah, blah..etc.)
    UnauthorizedAccessException doesnt work
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  4. #4
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    IOException is what gets thrown.

  5. #5

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Yeah. I just noticed that it will tell me the 'best' one when it goes off. Oh well. Generic IOException it is then.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  6. #6
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151
    May be u have opened this anyehre and not closed the reference
    Variety is the spice of life

  7. #7

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    No. Im not worried about what is causing an error. My question was about Exception types.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  8. #8
    Addicted Member
    Join Date
    Sep 2002
    Location
    India
    Posts
    151
    It is a baseclass of Exception class
    and throws if we acess a file which is in use
    need to be catched
    Variety is the spice of life

  9. #9

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Dude. I already know the answer to this. And that still isnt the appropriate answer anyway.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  10. #10
    PowerPoster Lethal's Avatar
    Join Date
    Oct 2000
    Location
    Ohio
    Posts
    2,496
    LOL.....Cander, I sometimes wonder was is going through the minds of some when they post answers like the above...

  11. #11

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    Well he was trying. I think he just misunderstood what i was asking.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

  12. #12

    Thread Starter
    Banished Cander's Avatar
    Join Date
    Dec 2000
    Location
    Why do you care?
    Posts
    6,913
    ohh I just found this. Under Debug on the VS menu, hit Exceptions. You get a nice list of exceptions. Very helpful.
    Stack Overflow
    See the features of Visual Studio 2010 and C# 4.0: The 10-4 show on Channel9

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  



Click Here to Expand Forum to Full Width