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. Urgent please: strange problem with file uploading

Urgent please: strange problem with file uploading

Scheduled Pinned Locked Moved ASP.NET
helphtmlasp-netquestion
2 Posts 2 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
    Member 1033907
    wrote on last edited by
    #1

    Hi there I upload files the same way everyone does: HTML:

    Code: FileUpload1.SaveAs(savePath); which works almost fine. When the code finishs, the file is saved in the desired location but it somehow remains open! (thus inaccessible for writing, deleting, etc.) until I restart aspnet_wp.exe. I am really stuck with this problem, because I even tried my own way of saving the file (instead of using SaveAs): int len = FileUpload1.PostedFile.ContentLength; byte[] buffer = new byte[len]; FileUpload1.PostedFile.InputStream.Read(buffer, 0, len); FileStream file = new FileStream(savePath, FileMode.Create); file.Write(buffer, 0, len); file.Close(); // notice that I don't forget to close the file But the problem survived - the file still remains open although I explicitly call .Close() which is pretty puzzling for me! Can anyone please help me out? Thanks thousand times, H.

    S 1 Reply Last reply
    0
    • M Member 1033907

      Hi there I upload files the same way everyone does: HTML:

      Code: FileUpload1.SaveAs(savePath); which works almost fine. When the code finishs, the file is saved in the desired location but it somehow remains open! (thus inaccessible for writing, deleting, etc.) until I restart aspnet_wp.exe. I am really stuck with this problem, because I even tried my own way of saving the file (instead of using SaveAs): int len = FileUpload1.PostedFile.ContentLength; byte[] buffer = new byte[len]; FileUpload1.PostedFile.InputStream.Read(buffer, 0, len); FileStream file = new FileStream(savePath, FileMode.Create); file.Write(buffer, 0, len); file.Close(); // notice that I don't forget to close the file But the problem survived - the file still remains open although I explicitly call .Close() which is pretty puzzling for me! Can anyone please help me out? Thanks thousand times, H.

      S Offline
      S Offline
      SABhatti
      wrote on last edited by
      #2

      Try this: Dim myFile As HttpPostedFile = getFile.PostedFile myFile.SaveAs(Server.MapPath(".") & "\upload\template.xls") this vb code and works just fine for uploding.... you can change it to c# easily.. Good Luck Salim Akbar

      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