saving file using new saving file using new unique filename didn't save all the file on the disk

Thread is closed for posting
5 posts, 1 answers
  1. ariefimansantoso
    ariefimansantoso avatar
    7 posts
    Member since:
    Sep 2006

    Posted 19 Feb 2008 Link to this post

    Hi,

    in a single asp.net page, i put 2 RadUpload "prometheus" control. i didn't set TargetFolder and TargetPhysicalFolder, because i want to handle the upload myself. I want to save files using unique file name that i generate myself.

    the problem is that when i use this unique file name, not all files that are uploaded are saved on the disk. I simulate this several time, I upload 5 files and only 3 or 4, even only 2 of them are saved on the harddisk, but when I use the original file name of the files uploaded, all of them are saved successfully on the harddisk. strangely, if I run it on debug mode (pressing F5) and go through the code line by line with F10, everything is working fine, all files are saved with unique filename.

    this is my code behind that handles the upload:

    if (RadUpload1.UploadedFiles.Count > 0)
    {
        foreach (Telerik.Web.UI.UploadedFile file1 in RadUpload1.UploadedFiles)
        {
             string newFilename = Tools.generateUniqueFilename() + file1.GetExtension();
             file1.SaveAs(Path.Combine(path, newFilename));
             images.Add(file1.FileName, file1);
             Literal1.Text += file1.FileName + " success<br/>";
         }
    }
    if (RadUpload2.UploadedFiles.Count > 0)
    {           
          foreach (Telerik.Web.UI.UploadedFile file2 in RadUpload2.UploadedFiles)
          {
              string newFilename = Tools.generateUniqueFilename() + file2.GetExtension();
              file2.SaveAs(Path.Combine(path, newFilename));
              images.Add(file2.FileName, file2);
              Literal1.Text += file2.FileName + " success<br/>";
         }
    }

    I appreciate for any help.

    regards,

    arief
  2. Petya
    Admin
    Petya avatar
    869 posts

    Posted 19 Feb 2008 Link to this post

    Hello ariefimansantoso,

    I tested the provided code with some modifications (as in the code from your post there are some missing classes such as Tools, etc.) but was not able to reproduce the problem. I suggest that you try to isolate the problem in a small running project and send it to us so we can run it and reproduce the issue. Please, include the bin folder and all necessary files and folders too. To be able to attach file to your thread you need to open a support ticket as described in the attached instructions.

    All the best,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  3. ariefimansantoso
    ariefimansantoso avatar
    7 posts
    Member since:
    Sep 2006

    Posted 19 Feb 2008 Link to this post

    Hi Petya,

    thanks for your reply.

    Tools class is actually a helper class that contains static methods such as generateUniqueFilename() to generate filename, in order to simulate my code, you can change path and you can hardcode some dummy filenames.

    this is actually just the beginning of my application (really simple and small), i Just use 2 RadUpload "Prometheus", each has 10 MaxFileInputCount of each RadUpload, and AllowedFileExtensions=".jpg,.jpeg". Then I simulate with uploading 2 images for the first control and 3 images for the second one, all images are JPG. All files are uploaded successfully when i don't change the filename, but when i do, maximum i only got 4 files uploaded successfully.

    by the way, I cannot download the instructions.zip that's why i wrote this reply.

    thanks again.

    regards,

    arief
  4. Petya
    Admin
    Petya avatar
    869 posts

    Posted 20 Feb 2008 Link to this post

    Hi ariefimansantoso,

    What prevents you from downloading the Instructions.zip I sent you? I will explain the instructions here but I need to know whether you have a problem downloading this specific file or you cannot download files in general because if the latter is true I cannot send you my test page. To open a support ticket you need to log into your Client.Net account on our web site, then go to My Support Tickets in the menu on the left, then Submit a support ticket. I tested again your scenario following the instructions you have explained and I am still not able to reproduce any problems so it would be better if you can open a support ticket and send us a simple running project with steps to reproduce.

    Kind regards,
    Petya
    the Telerik team

    Instantly find answers to your questions at the new Telerik Support Center
  5. Answer
    ariefimansantoso
    ariefimansantoso avatar
    7 posts
    Member since:
    Sep 2006

    Posted 22 Feb 2008 Link to this post

    Petya,

    It has been solved, the problem was the generation of unique filename, for some reasons the generator generates same file twice, even three times, this couses files to be rewritten.

    anyway thank you so much for your responses.

    regards,

    arief
Back to Top