This is a migrated thread and some comments may be shown as answers.

Problem with uploading file when TargetFolder doesn't exist

2 Answers 85 Views
Upload (Obsolete)
This is a migrated thread and some comments may be shown as answers.
Akki
Top achievements
Rank 1
Akki asked on 15 Mar 2012, 04:16 PM
Hi,
Any support on this ?  or no solution ??

I am getting crash when the TargetFolder="~/MYFiles" doesn't exist.. I tried to see whether folder exist on button click
but the crash appears before button click.. below is the code.

Can u help me out, how to check wether targetfolder exist or not.

 <telerik:RadUpload ID="RadUpload1" runat="server"
        ControlObjectsVisibility="CheckBoxes, AddButton, DeleteSelectedButton"
        TargetFolder="~/MYFiles" onfileexists="RadUpload1_FileExists" OverwriteExistingFiles="false">
  </telerik:RadUpload>

<asp:Button ID="btnUpload" runat="server" Text="Upload" onclick="btnUpload_Click"  />

C#
 protected void btnUpload_Click(object sender, EventArgs e)
    {
        if (RadUpload1.UploadedFiles.Count > 0)
        {
            string filename = Path.GetFileName(RadUpload1.UploadedFiles[0].GetName());
            if (System.IO.Directory.Exists(Server.MapPath(RadUpload1.TargetFolder)))
            {
            }
            else
            {  
            }
        }
    }

Regards,
Akki

2 Answers, 1 is accepted

Sort by
0
Akki
Top achievements
Rank 1
answered on 19 Mar 2012, 01:04 AM

Any support on this ?  or no solution ??

0
Dimitar Terziev
Telerik team
answered on 21 Mar 2012, 02:08 PM
Hi,

The problem in your case is caused by the fact that the button click event is fired a bit late and the RadUpload had already tried to save the file in the target folder. Please find a sample page showing how to proceed in scenarios like yours.

Greetings,
Dimitar Terziev
the Telerik team
If you want to get updates on new releases, tips and tricks and sneak peeks at our product labs directly from the developers working on the RadControls for ASP.NET AJAX, subscribe to their blog feed now.
Tags
Upload (Obsolete)
Asked by
Akki
Top achievements
Rank 1
Answers by
Akki
Top achievements
Rank 1
Dimitar Terziev
Telerik team
Share this question
or