The process cannot access the file because it is being used by another process.

2 posts, 0 answers
  1. zykes
    zykes avatar
    2 posts
    Member since:
    Jun 2011

    Posted 03 Dec 2013 Link to this post


    Im uploading a file using RadAsyncUpload control and I wanted to check if the image to be uploaded is really image, not just another file changed of extension name. Code below:

    The error is triggered on the .SaveAs() function

                String fileExt = rfile_image.UploadedFiles[0].FileName.Substring(rfile_image.UploadedFiles[0].FileName.LastIndexOf('.') + 1).ToUpper();
                byte[] tmp = imageHeader[fileExt];
                byte[] header = new byte[tmp.Length];
                rfile_image.UploadedFiles[0].InputStream.Read(header, 0, header.Length);
                if (!CompareArray(tmp, header))
                    //invalid content type
                    returnError("Filename Invalid");
                    //valid content type, continue with saving
                    fileUrl = "C:\\data\\" + fileWithPath;                
  2. Shinu
    Shinu avatar
    17764 posts
    Member since:
    Mar 2007

    Posted 23 Dec 2013 Link to this post

    Hi zykes,

    Try closing the stream rfile_image.UploadedFiles[0].InputStream.close() before attempting to save the file. Please have a look into this forum thread which deals with a similar scenario.

    Hope this helps,
Back to Top