How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

  •  10-05-2011, 9:58 AM

    How do i prevent the file from being saved to the tempdirectory when i am OpenStream to save the image myself ...

    I am trying to develop a page that will upload image.  Once the _UploadCompleted event is trigger I uses args.OpenStream to create a new drawing image that i use to shrink and convert the image into png with rounded corners.  I than save the file into a specific folder on my server.  My Problem is the control is still coping a version of the file to the TempDirectory Folder.
     
    Is there a way to stop this? or do i just have to delete the file later?
     
    Also, which event should i place my code in?
    protected void PersistedFile1_FileUploaded(object sender, UploaderEventArgs args)
    protected void PersistedFile1_FileValidating(object sender, UploaderEventArgs args)
    protected void PersistedFile1_UploadCompleted(object sender, UploaderEventArgs[] args)
    protected void PersistedFile1_Init(object sender, EventArgs e);


    The Code i use to copy the upload file..
    int
    roundedDia = 25;
    System.Drawing.Image myImage = System.Drawing.Image.FromStream( args.OpenStream() );
    Bitmap bitmap = new Bitmap(imgin.Width, imgin.Height);
    Graphics g = Graphics.FromImage(bitmap);
    g.Clear(
    Color.Transparent);
    g.SmoothingMode = (System.Drawing.Drawing2D.
    SmoothingMode.AntiAlias);
    Brush brush = new System.Drawing.TextureBrush(imgin);
    FillRoundedRectangle(g,
    new Rectangle(0, 0, imgin.Width, imgin.Height), roundedDia, brush);
    bitmap.Save(@mPath + "Completed" + ".png", System.Drawing.Imaging.ImageFormat.Png);
     
View Complete Thread