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

Custom Error from StoreFile()

4 Answers 119 Views
FileExplorer
This is a migrated thread and some comments may be shown as answers.
Chris
Top achievements
Rank 1
Chris asked on 29 May 2009, 08:50 PM
In my Custom ContentProvider, is there a way to return an error string from StoreFile()?

4 Answers, 1 is accepted

Sort by
0
Fiko
Telerik team
answered on 01 Jun 2009, 10:10 AM
Hi Chris,

The StoreFile function returns the path to the stored item and we do not recommend you replace that behavior. Could you please provide more details on what exactly you want to achieve?



Sincerely yours,
Fiko
the Telerik team

Instantly find answers to your questions on the new Telerik Support Portal.
Check out the tips for optimizing your support resource searches.
0
Adam
Top achievements
Rank 1
answered on 19 Jul 2011, 05:54 PM
I also have a need for this. We are using the custom file provider example to allow people to have access to their home directory when they are not on site. However, they have a limited amount of space. When they hit their space limit, I'd like to report a nice message instead of it just throwing an exception. The exception that is being caused when they run out of space is: There is not enough space on the disk.
0
juan
Top achievements
Rank 1
answered on 21 Jul 2011, 03:28 PM
i have the same problem,  i want to verify if i have space in the hard disk when the users upload files or the extension file using my code. Who is posible to verify this and put the message in the frontend?
Thanks.
0
Dobromir
Telerik team
answered on 22 Jul 2011, 12:26 PM
Hi guys,

To achieve the required functionality you can override the StoreFile() method of the content provider, handle the exception and use the ScriptManager.RegisterStartupScript() to display an alert with the custom message. You can get reference to the Page object from the content provider using the following code:
var page = HttpContext.Current.Handler as Page;

The following is a sample StoreFile() method that pop-ups an alert:
public override string StoreFile(UploadedFile file, string path, string name, params string[] arguments)
{
    try
    {
        throw new IOException("Forced Exception");
    }
    catch (IOException e)
    {
        var page = HttpContext.Current.Handler as Page;
 
        ScriptManager.RegisterStartupScript(page, page.GetType(), "key", @"alert(""Custom Error Message!"");", true);
    }
 
    return base.StoreFile(file, path, name, arguments);
}

I hope this helps.

Regards,
Dobromir
the Telerik team

Register for the Q2 2011 What's New Webinar Week. Mark your calendar for the week starting July 18th and book your seat for a walk through of all the exciting stuff we will ship with the new release!

Tags
FileExplorer
Asked by
Chris
Top achievements
Rank 1
Answers by
Fiko
Telerik team
Adam
Top achievements
Rank 1
juan
Top achievements
Rank 1
Dobromir
Telerik team
Share this question
or