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.IOException Please help me

System.IO.IOException Please help me

Scheduled Pinned Locked Moved ASP.NET
databasehelp
3 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.
  • C Offline
    C Offline
    cheguri
    wrote on last edited by
    #1

    Dear friends, I am trying to upload one excel file to sqlserver database by using fileupload control. I am initially uploading the file and saving in a temporary folder and from this temporary folder I am copying the data to SqlServer Table. After copying the data, I want to delete the file in Temporary Folder. I wrote File.Delete(filename) code, but it is throwing following exception [System.IO.IOException] = {"The process cannot access the file 'E:\\SourceSafe\\ESSP\\Finance\\FinancePL\\uploadedfiles\\samplePS.xls' because it is being used by another process."} It is not allowing to delete the file. Please, can anyone help me in this. It's very urgent. Please.... Thanks, Dileep.

    S P 2 Replies Last reply
    0
    • C cheguri

      Dear friends, I am trying to upload one excel file to sqlserver database by using fileupload control. I am initially uploading the file and saving in a temporary folder and from this temporary folder I am copying the data to SqlServer Table. After copying the data, I want to delete the file in Temporary Folder. I wrote File.Delete(filename) code, but it is throwing following exception [System.IO.IOException] = {"The process cannot access the file 'E:\\SourceSafe\\ESSP\\Finance\\FinancePL\\uploadedfiles\\samplePS.xls' because it is being used by another process."} It is not allowing to delete the file. Please, can anyone help me in this. It's very urgent. Please.... Thanks, Dileep.

      S Offline
      S Offline
      Sandeep Mewara
      wrote on last edited by
      #2

      Lots of information missing though. The moment you uploaded it to temp folder, how do you upload it to database? Is the upload to DB process simultaneously going on? Immediately or afterwards? Is that process of uploading to DB is in progress when you try to delete it? Looks like the temporary folder is a Sourcesafe folder. Those are write protected. Lastly, you should directly upload it to DB instead of inserting an extra step in between and having a performance hit!

      1 Reply Last reply
      0
      • C cheguri

        Dear friends, I am trying to upload one excel file to sqlserver database by using fileupload control. I am initially uploading the file and saving in a temporary folder and from this temporary folder I am copying the data to SqlServer Table. After copying the data, I want to delete the file in Temporary Folder. I wrote File.Delete(filename) code, but it is throwing following exception [System.IO.IOException] = {"The process cannot access the file 'E:\\SourceSafe\\ESSP\\Finance\\FinancePL\\uploadedfiles\\samplePS.xls' because it is being used by another process."} It is not allowing to delete the file. Please, can anyone help me in this. It's very urgent. Please.... Thanks, Dileep.

        P Offline
        P Offline
        P S Pundeer
        wrote on last edited by
        #3

        You have to release resources used during the first phase of your code, which is saving file into physical space/directory. For example:

        fileObjectUsed.dispose();

        OR

        FileUpload1.dispose();

        I would recommend you not to store file into your web server location as this will add extra overhead of saving and deleting files and of-course security problem. You can directly store it(file) into database by converting it to bytes. Check out the link Storing Binary Data to Database using ASP.NET 2.0[^] Observe the code lines...

        Dim imageBytes(fileUpload1.PostedFile.InputStream.Length) As Byte
        fileUpload1.PostedFile.InputStream.Read(imageBytes, 0, imageBytes.Length)

        puranonnet@hotmail.com BCS Technology

        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