OverwriteExistingFile

10 posts, 1 answers
  1. Lynda Lafreniere
    Lynda Lafreniere avatar
    33 posts
    Member since:
    Oct 2006

    Posted 12 Aug 2009 Link to this post

    Hi everyone,

    I would like to know if the "OverwriteExistingFile" property of the RadUpload in the RadFileExplorer is supposed to control the related checkbox in the RadWindow ? On my side it doesn't and I don't think it's normal.

    If the property and the checkbox are not related, is there a server-side way to know that the user has check the "Overwrite if a file exist" checkbox (in the OnItemCommand event if possible) ?

    I use the ASP.NET AJAX 2009 Q2 version of the controls and I've tried both on IE8 and FF3.5.

    Thanks !!
  2. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 13 Aug 2009 Link to this post

    Hi Lynda ,

    The "Overwrite if file exists?" checkbox works as expected on our side and we are not quite sure what is causing the problem in your case. Could you please open a new support ticket and send us a full sample project which reproduces the problem? As an alternative, you could modify the attached test project and send it back. Once we have a better view over your scenario and the problems with it, we will do our best to provide a solution.

    Best wishes,
    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.
  3. UI for ASP.NET Ajax is Ready for VS 2017
  4. Lynda Lafreniere
    Lynda Lafreniere avatar
    33 posts
    Member since:
    Oct 2006

    Posted 17 Aug 2009 Link to this post

    Hi,

    I'll try first to explain more clearly my situation because our project is now quite big.

    We want to use the RadFileManager to manage the files of our users. Users can send us varieties of files (.pdf, .doc, .docx, .txt, etc.) and we convert all these file in pdf. To check if the file really exist, I have to check if there is a pdf with the same name but I will only do this verification if the checkbox "overwrite file" is not checked (if it's checked, I'll overwrite the file manually).

    Example:
    User1 try to upload "test.doc" --> I check if the checkbox "overwrite" in the upload window was checked --> if not checked, I verify if there's a file named "test.pdf" --> if exist, I stop the operation and I show an error message to User1

    To do this, I use the "OnItemCommand" event.

    Here's the file_manager call
    <rad:RadFileExplorer ID="file_explorer" runat="server" EnableCreateNewFolder="false" VisibleControls="Grid,Toolbar,ContextMenus,TreeView"  
                TreePaneWidth="150px" Width="100%" Configuration-MaxUploadFileSize="1024000" AllowPaging="false" 
                OnItemCommand="file_explorer_ItemCommand" /> 

    And here's the ItemCommand code.
    protected void file_explorer_ItemCommand(object sender, RadFileExplorerEventArgs e) 
        { 
            if (e.Command == "UploadFile"
            { 
                RadUpload upload = (sender as RadFileExplorer).Upload; 
     
                // If do not overwrite, check if file exists 
                if (!upload.OverwriteExistingFiles) 
                { 
                    // CODE THAT CHECK THE FILE AND SHOW THE MESSAGE
                    (...)
                } 
            } 
        } 

    The problem is that the line "upload.OverwriteExistingFiles" is always "false", even if I checked the "Overwrite existing file" checkbox. In my last try, there's nothing else in the page and the only other code is to set the paths.

    Is there another property that I don't know or do there's another way the get the checkbox value ??

    Thank you !!


  5. Answer
    Lini
    Admin
    Lini avatar
    2144 posts

    Posted 18 Aug 2009 Link to this post

    Hi,

    The upload control does not actually save the files. This operation is done from the file explorer's content provider. This is why the OverriteExistingFiles property of the upload is not set in the RadFileExplorer. To get the state of the checkbox, you need to access it directly. Here is some code that will help you:

    CheckBox chkOverwrite = (CheckBox)RadFileExplorer1.FindControl("chkOverwrite"); 
    if (!chkOverwrite.Checked) 
    //... 
     

    where RadFileExplorer1 is your file explorer control. I hope this helps.

    All the best,
    Lini
    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.
  6. Lynda Lafreniere
    Lynda Lafreniere avatar
    33 posts
    Member since:
    Oct 2006

    Posted 18 Aug 2009 Link to this post

    Hi,

    now it makes more sense  :) !

    Thanks a lot !!
  7. Thriveni
    Thriveni avatar
    2 posts
    Member since:
    Dec 2010

    Posted 06 Dec 2010 Link to this post

    Hi Team,

    I  have an issue with radfileexplorer() control.i have overriden getFile() and StoreFile() methods in my custom filebrowsercontent provider.and i have override the __ItemCommand event to display the custom message.
    when the evet fires the default message that is Message from webpage is also firing along with the custom message.

    could you please let me know how can I remove the default alert message.that i.e .

    ---------------------------
    Message from webpage
    ---------------------------
    A file with a name same as the target already exists!
    ---------------------------
    OK  
    ---------------------------


    please suggest to remove this alert message.
    Thanks in Advance.

    Regards,
    Thriveni
  8. Fiko
    Admin
    Fiko avatar
    1406 posts

    Posted 09 Dec 2010 Link to this post

    Hello Thriveni,

    This message is fired automatically by the RadFileExplorer control when the GetFile method (a part of the ContentProvider) returns a different value than null (Nothing in VB.NET). RadFileExplorer calls this method in order to check whether a file exists or not, so you can override it to return a null (or Nothing) value.

    The better solution, however, is to use the RadFileExplorer's localization files (RadEditor and RadFileExplorer share some of the .resx files) in order to change the showed message.

    Kind regards,
    Fiko
    the Telerik team
    Browse the vast support resources we have to jumpstart your development with RadControls for ASP.NET AJAX. See how to integrate our AJAX controls seamlessly in SharePoint 2007/2010 visiting our common SharePoint portal.
  9. Vishal
    Vishal avatar
    5 posts
    Member since:
    Sep 2012

    Posted 21 Sep 2012 Link to this post

    Hi,

    I tried following but it's not working. Do I need to copy all the files or just RadEditor.Dialogs.resx ?
    Regards
    Vishal.
  10. Vessy
    Admin
    Vessy avatar
    1388 posts

    Posted 24 Sep 2012 Link to this post

    Hi Vishal,

    The Common_FileExists's message value is declared in the RadEditor.Dialogs.resx file so it is enough if only this file(with the changed value) is copied. Could you, please, elaborate on what exactly do you mean with "I tried following but it's not working"?

    • If the message has not been changed at all, could you ensure it the RadEditor.Dialogs.resx is copied in a folder named App_GlobalResources folder, which is placed in your application's root.

    • Could you verify if this is the exact value which is changed on your side?
    <data name="Common_FileExists" xml:space="preserve">
        <value>A file with a name same as the target already exists!</value>
    </data>

    Please, note, that if you are trying to prevent the whole dialog opening by setting the above quoted value to an empty string it is not possible. This approach could be used only in order to change the default dialog's message.

    Greetings,
    Vesi
    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.
  11. Vishal
    Vishal avatar
    5 posts
    Member since:
    Sep 2012

    Posted 24 Sep 2012 Link to this post

    Hi Vesi,

    Thanks for your reply. Sorry what I meant was: I tried the steps as per the link below
    http://www.telerik.com/help/aspnet-ajax/editor-using-global-resource-files.html

    i.e. Copy into local folder and also remove 'Common_FileExists' but it still came up with the dialog box while uploading the file.
    Even if I upload the file for the first time it still comes up with a message saying 'the file with same name exists' so where does it check for the file existsance?


    Regards

    Vishal
Back to Top
UI for ASP.NET Ajax is Ready for VS 2017