Disk Full error...on certain file and driectory create/copy methods

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • VJ

    Disk Full error...on certain file and driectory create/copy methods

    I have these functions in my application.

    FileInfo.CopyTo

    DirectoryInfo.C reate

    File.Copy

    Directory.Creat e

    Do these methods generate a exception when the DISK is full were they are
    trying to create a directory or copy a file? If so what is the exception?

    VJ



  • Herfried K. Wagner [MVP]

    #2
    Re: Disk Full error...on certain file and driectory create/copy methods

    * "VJ" <vijaybalki@yah oo.com> scripsit:[color=blue]
    > I have these functions in my application.
    >
    > FileInfo.CopyTo
    >
    > DirectoryInfo.C reate
    >
    > File.Copy
    >
    > Directory.Creat e
    >
    > Do these methods generate a exception when the DISK is full were they are
    > trying to create a directory or copy a file? If so what is the exception?[/color]

    I didn't test it, but maybe an 'IOException'.. .

    --
    Herfried K. Wagner [MVP]
    <http://www.mvps.org/dotnet>

    Comment

    • José Manuel Agüero

      #3
      Re: Disk Full error...on certain file and driectory create/copy methods

      Hello, VJ:

      You can test it using a diskette: Fill it with some files and then test the methods.
      Under XP you can assign a user a very small disk quota and fill it for testing.

      Anyway .NET doesn't handle disk full conditions very well. If it bothers you, you may test for enough free space before writing to disk.

      Regards.


      "VJ" <vijaybalki@yah oo.com> escribió en el mensaje news:OuMzd$HsDH A.2444@TK2MSFTN GP12.phx.gbl...
      | I have these functions in my application.
      |
      | FileInfo.CopyTo
      |
      | DirectoryInfo.C reate
      |
      | File.Copy
      |
      | Directory.Creat e
      |
      | Do these methods generate a exception when the DISK is full were they are
      | trying to create a directory or copy a file? If so what is the exception?
      |
      | VJ
      |
      |
      |

      Comment

      • Cor

        #4
        Re: Disk Full error...on certain file and driectory create/copy methods

        Hi Jose,

        that is clever
        [color=blue]
        >You can test it using a diskette: Fill it with some files and then test the[/color]
        methods.[color=blue]
        >Under XP you can assign a user a very small disk quota and fill it for[/color]
        testing.

        Cor


        Comment

        • José Manuel Agüero

          #5
          Re: Disk Full error...on certain file and driectory create/copy methods

          Thanks, Cor.

          I found something weird:

          Class FullDiskTest
          Public Shared Sub Main()
          Dim arch As System.IO.FileS tream
          Dim a(511) As Byte
          arch = New System.IO.FileS tream("a:\che.b in", System.IO.FileM ode.OpenOrCreat e)
          Try
          arch.Seek(13000 00, System.IO.SeekO rigin.Begin) 'Useful from the second time it runs...
          Do
          arch.Write(a, 0, 512)
          Loop
          Catch exc As System.Exceptio n
          System.Console. WriteLine(exc.T oString)
          End Try
          'Everything fine until now.
          Try
          arch.Close() 'Generates a Disk Full exception... and the file is not closed!
          Catch exc As System.IO.IOExc eption
          System.Console. WriteLine(exc.T oString)
          End Try
          System.Console. ReadLine()
          End Sub
          'The program exits with an unhandled exception!
          End Class


          I have changed the arch.Close() line with theese others:
          arch=nothing
          System.GC.Colle ct() '(Generates an exception only inside the IDE)
          System.GC.WaitF orPendingFinali zers()

          Theese last lines generate an unhandled exception (although they are inside the Try block).
          The file is not unlocked until the program exits.
          It seems to me that a Full Disk Exception is generated when the GC tries to close the file, but the GC doesn't handle the error, neither propagate it to the program.

          Well, can anybody test it and tell me if it is the expected behavior?

          Regards.


          "Cor" <non@non.com> escribió en el mensaje news:%23a8sk1Rs DHA.3492@TK2MSF TNGP11.phx.gbl. ..
          | Hi Jose,
          |
          | that is clever
          |
          | >You can test it using a diskette: Fill it with some files and then test the
          | methods.
          | >Under XP you can assign a user a very small disk quota and fill it for
          | testing.
          |
          | Cor
          |
          |

          Comment

          • Cor

            #6
            Re: Disk Full error...Bug?

            Hi Jose,

            I think you are right.

            I did also try it with the streamwriter, to be sure that it was not an
            incident.

            It seems if that if you try to close after that an error is thrown because
            of a diskfull and the command is not executed and then when you try to end
            your program, the framework tries again to close it automaticly but has no
            room for it and you are even not able to undo your operation.

            I did try to catch it in the closing and close event to be sure that there
            was no escape and that was not working either.

            Cor


            Comment

            • Cor

              #7
              Re: Disk Full error...Bug?

              Hi Jose,

              I think you are right.

              I did also try it with the streamwriter, to be sure that it was not an
              incident.

              It seems if that if you try to close after that an error is thrown because
              of a diskfull and the command is not executed and then when you try to end
              your program, the framework tries again to close it automaticly but has no
              room for it and you are even not able to undo your operation.

              I did try to catch it in the closing and close event to be sure that there
              was no escape and that was not working either.

              Cor


              Comment

              • Herfried K. Wagner [MVP]

                #8
                Re: Disk Full error...Bug?

                * "Cor" <non@non.com> scripsit:[color=blue]
                > It seems if that if you try to close after that an error is thrown because
                > of a diskfull and the command is not executed and then when you try to end
                > your program, the framework tries again to close it automaticly but has no
                > room for it and you are even not able to undo your operation.[/color]

                'StreamWriter' uses a buffer, that's why the error doesn't show up
                directly when writing into the file. Calling the 'Close' method will
                make data in the buffer persistent, then an error may occur.

                --
                Herfried K. Wagner [MVP]
                <http://www.mvps.org/dotnet>

                Comment

                • Cor

                  #9
                  Re: Disk Full error...Bug?

                  Hi Herfried,

                  And what is the solution?

                  I did delete the close and then the error shows up direct, but what to
                  prevent the error but take some actions?

                  Cor
                  [color=blue][color=green]
                  > > It seems if that if you try to close after that an error is thrown[/color][/color]
                  because[color=blue][color=green]
                  > > of a diskfull and the command is not executed and then when you try to[/color][/color]
                  end[color=blue][color=green]
                  > > your program, the framework tries again to close it automaticly but has[/color][/color]
                  no[color=blue][color=green]
                  > > room for it and you are even not able to undo your operation.[/color]
                  >
                  > 'StreamWriter' uses a buffer, that's why the error doesn't show up
                  > directly when writing into the file. Calling the 'Close' method will
                  > make data in the buffer persistent, then an error may occur.
                  >[/color]


                  Comment

                  • Herfried K. Wagner [MVP]

                    #10
                    Re: Disk Full error...Bug?

                    * "Cor" <non@non.com> scripsit:[color=blue]
                    > And what is the solution?
                    >
                    > I did delete the close and then the error shows up direct, but what to
                    > prevent the error but take some actions?[/color]

                    If I would know a solution, I would have posted it.

                    ;-)

                    --
                    Herfried K. Wagner [MVP]
                    <http://www.mvps.org/dotnet>

                    Comment

                    • Cor

                      #11
                      Re: Disk Full error...Bug?

                      Herfried,
                      [color=blue]
                      >
                      > If I would know a solution, I would have posted it.[/color]

                      When I would thought that you had a solution for the problem, I did not have
                      asked this question, but I will prevent that Microsoft people think that
                      they don't have to document this bug (if we not see it wrong) and in some
                      answers from you (and maybe I do the same) it sometimes seems that the
                      problem is gone, while it is not..

                      This behaviour (not yours or mine) is very bad (the buffering is right as
                      you say, but that I can understand myself and even if it not was a buffer it
                      would have to write some file information if it really should closing).

                      The problem is not that you cannot write, the problem is that you cannot
                      prevent the try to write or let say it better to dispose the streamreader
                      object in a decent way.

                      Cor


                      Comment

                      • VJ

                        #12
                        Re: Disk Full error...on certain file and driectory create/copy methods

                        I found this on the net.. sounds like a bug in the filestream class in the
                        framework.. Hope this helps everybody..



                        BTW.. thanks folks for all answers...

                        VJ

                        "VJ" <vijaybalki@yah oo.com> wrote in message
                        news:OuMzd$HsDH A.2444@TK2MSFTN GP12.phx.gbl...[color=blue]
                        > I have these functions in my application.
                        >
                        > FileInfo.CopyTo
                        >
                        > DirectoryInfo.C reate
                        >
                        > File.Copy
                        >
                        > Directory.Creat e
                        >
                        > Do these methods generate a exception when the DISK is full were they are
                        > trying to create a directory or copy a file? If so what is the exception?
                        >
                        > VJ
                        >
                        >
                        >[/color]


                        Comment

                        Working...