Skip to content
  • Categories
  • Recent
  • Tags
  • Popular
  • World
  • Users
  • Groups
Skins
  • Light
  • Cerulean
  • Cosmo
  • Flatly
  • Journal
  • Litera
  • Lumen
  • Lux
  • Materia
  • Minty
  • Morph
  • Pulse
  • Sandstone
  • Simplex
  • Sketchy
  • Spacelab
  • United
  • Yeti
  • Zephyr
  • Dark
  • Cyborg
  • Darkly
  • Quartz
  • Slate
  • Solar
  • Superhero
  • Vapor

  • Default (No Skin)
  • No Skin
Collapse
Code Project
  1. Home
  2. Web Development
  3. ASP.NET
  4. System.IO Problem?

System.IO Problem?

Scheduled Pinned Locked Moved ASP.NET
questionhelp
6 Posts 3 Posters 0 Views 1 Watching
  • Oldest to Newest
  • Newest to Oldest
  • Most Votes
Reply
  • Reply as topic
Log in to reply
This topic has been deleted. Only users with topic management privileges can see it.
  • M Offline
    M Offline
    MudkiSekhon
    wrote on last edited by
    #1

    Hi I want to create Directories and Files in my project. But I don't want to use static methods of System.IO.Directory and System.IO.File because they are causing exceptions for some methods that this file is being used by some other process. How can I do this with classes from which we can make instance objects. I don't want to predefine the path or the file while creating new instance of the object. Thanks, Sandy

    J 1 Reply Last reply
    0
    • M MudkiSekhon

      Hi I want to create Directories and Files in my project. But I don't want to use static methods of System.IO.Directory and System.IO.File because they are causing exceptions for some methods that this file is being used by some other process. How can I do this with classes from which we can make instance objects. I don't want to predefine the path or the file while creating new instance of the object. Thanks, Sandy

      J Offline
      J Offline
      J4amieC
      wrote on last edited by
      #2

      If you are trying to write to a file that is in use, then it wont make a difference how you try, you wont get to write to that file. Using the static File and Directory methods is no different to using FileInfo and DirectoryInfo - which respectivly are the "instance" versions that you refer to. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

      M 1 Reply Last reply
      0
      • J J4amieC

        If you are trying to write to a file that is in use, then it wont make a difference how you try, you wont get to write to that file. Using the static File and Directory methods is no different to using FileInfo and DirectoryInfo - which respectivly are the "instance" versions that you refer to. Current blacklist svmilky - Extremely rude | FeRtoll - Rude personal emails | ironstrike1 - Rude & Obnoxious behaviour

        M Offline
        M Offline
        MudkiSekhon
        wrote on last edited by
        #3

        In my application , I am uploading the images from the client. Then I am creating Directories to save those files. I have also functions to delete those files if the user want to do so. But after deleting the file and again uploading the new file to the same location give me the exception that this path or file is being used by another process. Now I am using FileInfo static methods to delete and save file but when I want to save file using FileControl by FileControlName.PostedFile.SaveAs(FilePath) method, it raises the above said exception. Thanks, Sandy

        P 1 Reply Last reply
        0
        • M MudkiSekhon

          In my application , I am uploading the images from the client. Then I am creating Directories to save those files. I have also functions to delete those files if the user want to do so. But after deleting the file and again uploading the new file to the same location give me the exception that this path or file is being used by another process. Now I am using FileInfo static methods to delete and save file but when I want to save file using FileControl by FileControlName.PostedFile.SaveAs(FilePath) method, it raises the above said exception. Thanks, Sandy

          P Offline
          P Offline
          Paddy Boyd
          wrote on last edited by
          #4

          Are you sure you are properly closing your filestreams upon completion?

          M 1 Reply Last reply
          0
          • P Paddy Boyd

            Are you sure you are properly closing your filestreams upon completion?

            M Offline
            M Offline
            MudkiSekhon
            wrote on last edited by
            #5

            Please tell me the method to save a user uploaded file with the help of filestream . I had seen all the overload methods for declaring an object of FileStream object but all the methods demand the predefined FileName in the constructor. That is why I am using FileInfo class objects to perform those functions. But I couldn't find any function to close the FileInfo object. Thanks, Sandy

            P 1 Reply Last reply
            0
            • M MudkiSekhon

              Please tell me the method to save a user uploaded file with the help of filestream . I had seen all the overload methods for declaring an object of FileStream object but all the methods demand the predefined FileName in the constructor. That is why I am using FileInfo class objects to perform those functions. But I couldn't find any function to close the FileInfo object. Thanks, Sandy

              P Offline
              P Offline
              Paddy Boyd
              wrote on last edited by
              #6

              Quick google.[^]

              1 Reply Last reply
              0
              Reply
              • Reply as topic
              Log in to reply
              • Oldest to Newest
              • Newest to Oldest
              • Most Votes


              • Login

              • Don't have an account? Register

              • Login or register to search.
              • First post
                Last post
              0
              • Categories
              • Recent
              • Tags
              • Popular
              • World
              • Users
              • Groups