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. File access problem

File access problem

Scheduled Pinned Locked Moved ASP.NET
helpasp-net
4 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
    MihirV
    wrote on last edited by
    #1

    hi all i have problem in file IO, if one of you can solve the problem i will very thank full to him/her... Description: i hv one page that enables the user to upload file, for that i use HttpInputFile control to receive posted file by user. i can save posted file but i can not delete that posted file, it is throwing an Exception "System.IO.IOException: The process cannot access the file ". another process 'aspnet_wp.exe' is accessing the same file. Code:

    void SaveFile()
    {
    filInput.PostedFile.SaveAs(filename);
    //Validation code to check the file whether it is valid or not
    //if invliad delete the file and show message
    File.Delete(filename); // Error line
    }
    

    Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

    G V M 3 Replies Last reply
    0
    • M MihirV

      hi all i have problem in file IO, if one of you can solve the problem i will very thank full to him/her... Description: i hv one page that enables the user to upload file, for that i use HttpInputFile control to receive posted file by user. i can save posted file but i can not delete that posted file, it is throwing an Exception "System.IO.IOException: The process cannot access the file ". another process 'aspnet_wp.exe' is accessing the same file. Code:

      void SaveFile()
      {
      filInput.PostedFile.SaveAs(filename);
      //Validation code to check the file whether it is valid or not
      //if invliad delete the file and show message
      File.Delete(filename); // Error line
      }
      

      Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

      G Offline
      G Offline
      Guffa
      wrote on last edited by
      #2

      Perhaps it's something similar to saving images, then you have to dispose of the image object before you can delete the file. There is no dispose method for uploaded files, though. Can't you just verify the data before you save it as a file? --- b { font-weight: normal; }

      1 Reply Last reply
      0
      • M MihirV

        hi all i have problem in file IO, if one of you can solve the problem i will very thank full to him/her... Description: i hv one page that enables the user to upload file, for that i use HttpInputFile control to receive posted file by user. i can save posted file but i can not delete that posted file, it is throwing an Exception "System.IO.IOException: The process cannot access the file ". another process 'aspnet_wp.exe' is accessing the same file. Code:

        void SaveFile()
        {
        filInput.PostedFile.SaveAs(filename);
        //Validation code to check the file whether it is valid or not
        //if invliad delete the file and show message
        File.Delete(filename); // Error line
        }
        

        Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

        V Offline
        V Offline
        VenkataRamana Gali
        wrote on last edited by
        #3

        Hi Mihir, To resolve this we have 2 ways One manin thign is make sure that Your virtual directory property directory access authentication is set to "Windows Integrated Authentication" another(this is not compulsary) is check weather that uploaded file attributes are read only or not. if read only remove like this // remove readonly attribute of the file if ((f.Attributes & System.IO.FileAttributes.ReadOnly) != 0) { f.Attributes -= System.IO.FileAttributes.ReadOnly; } System.IO.File.Delete(f.FullName); regards GV Ramana

        1 Reply Last reply
        0
        • M MihirV

          hi all i have problem in file IO, if one of you can solve the problem i will very thank full to him/her... Description: i hv one page that enables the user to upload file, for that i use HttpInputFile control to receive posted file by user. i can save posted file but i can not delete that posted file, it is throwing an Exception "System.IO.IOException: The process cannot access the file ". another process 'aspnet_wp.exe' is accessing the same file. Code:

          void SaveFile()
          {
          filInput.PostedFile.SaveAs(filename);
          //Validation code to check the file whether it is valid or not
          //if invliad delete the file and show message
          File.Delete(filename); // Error line
          }
          

          Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

          M Offline
          M Offline
          MihirV
          wrote on last edited by
          #4

          thanks to both.. i have solved the problem.. problem was with SmartNavigation property of the page, i dont know why it is happening. i had set this property to True. By restoring the default value problem has solved. Confidence comes not from always being right, but from not fearing to be wrong..... Mihir..

          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