Re: Authentication required

  •  01-11-2010, 7:49 PM

    Re: Authentication required

    Hi,
     
    How do you copy the temporary file to the folder ?
     
    I think the reason is that the temp file have special permission setting in windows temp folder.
     
    And when you copy it to website folder, the permission is also copied.
     
    Maybe you can try this way :
     

     void Uploader_FileUploaded(object sender, UploaderEventArgs args)
     {
      string newfilepath = Path.Combine(Server.MapPath("~/myfolder"), args.FileName);
      using (FileStream newfile = new FileStream(newfilepath, FileMode.Create, FileAccess.Write, FileShare.None))
      {
       using (Stream srcfile = args.OpenStream())
       {
        byte[] buff = new byte[65536];
        int rc;
        while (true)
        {
         rc = srcfile.Read(buff, 0, buff.Length);
         if (rc <= 0)
          break;
         newfile.Write(buff, 0, rc);
        }
       }
      }
     }

     
    Regards,
    Terry
View Complete Thread