How Can I change FileName in The Target Folder

11 posts, 0 answers
  1. Ahmed
    Ahmed avatar
    55 posts
    Member since:
    Oct 2012

    Posted 01 Jan 2011 Link to this post

    How can I change File Name in The Target Folder Thats Mean if I Upload File its name Is "MyFile" i want to save it in My Solution as "123456789MyFile" i want to concatenate its name with Numeric Value
  2. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 03 Jan 2011 Link to this post

    Hi Ahmed,

    You can handle the FileUploadStarting() event to implement your scenario:
    private void RadUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
    {
        string[] nameParts = e.UploadData.FileName.Split('.');
        string fileName = nameParts[0] + (++this.uploadedFiles).ToString();
        int i = e.UploadData.FileName.LastIndexOf('.');
        if (i >= 0 && i < e.UploadData.FileName.Length)
        {
            fileName += e.UploadData.FileName.Substring(i);
        }
        e.UploadData.FileName = fileName;
    }

    You can have a look at this KB article for more info. You can also take a look at this article explaining how to save files on the server with unique names. I hope this info will help you.

    Kind regards,
    Tina Stancheva
    the Telerik team
    Browse the videos here>> to help you get started with RadControls for Silverlight
  3. DevCraft banner
  4. Angie
    Angie avatar
    33 posts
    Member since:
    Jul 2010

    Posted 05 Apr 2011 Link to this post

    this give Invalid cross-thread access. error when uploading multiple files

    code used

     private void RadUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
    {
        e.UploadData.FileName = RenameToAnotherName(e.UploadData.FileName);
    } Then i used
     private void RadUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
    {
    Deployment.Current.Dispatcher.BeginInvoke(() => 
                                     {
                                         e.UploadData.FileName = RenameToAnotherName(e.UploadData.FileName);
                                     }); 
    }
    
    That doesn't change e.UploadData.FileName. Please help.
    
          
  5. Angie
    Angie avatar
    33 posts
    Member since:
    Jul 2010

    Posted 06 Apr 2011 Link to this post

    For some reason example works i wonder whether this is a telerik version issue. Every time i try multiple file uploads i get the Invalid cross threak access issue

    here is more info regarding the error i get.

    {System.UnauthorizedAccessException: Invalid cross-thread access.
       at MS.Internal.XcpImports.CheckThread()
       at System.Windows.DependencyObject.GetValueInternal(DependencyProperty dp)
       at System.Windows.FrameworkElement.GetValueInternal(DependencyProperty dp)
       at System.Windows.FrameworkElement.get_DataContext()
       at RAMDirectHomeowners.View.SubmitAppView.RenameToDHName(String fileName)
       at RAMDirectHomeowners.View.SubmitAppView.RadUpload_FileUploadStarting(Object sender, FileUploadStartingEventArgs e)
       at Telerik.Windows.Controls.RadUpload.OnPreviewFileUploadStarting(Object sender, FileUploadStartingEventArgs e)
       at Telerik.Windows.Controls.RadUpload.OnFileUploadStarting(Object sender, EventArgs e)
       at Telerik.Windows.Controls.UploadDispatcher.OnStarting(FileUploadStartingEventArgs e)
       at Telerik.Windows.Controls.UploadDispatcher.PrepareFileUploadStarting()
       at Telerik.Windows.Controls.UploadDispatcher.UploadNextChunk()
       at Telerik.Windows.Controls.UploadDispatcher.OnResponse(IAsyncResult asyncResult)
       at System.Net.Browser.BrowserHttpWebRequest.<>c__DisplayClassd.<InvokeGetResponseCallback>b__b(Object state2)
       at System.Threading.QueueUserWorkItemCallback.WaitCallback_Context(Object state)
       at System.Threading.ExecutionContext.Run(ExecutionContext executionContext, ContextCallback callback, Object state, Boolean ignoreSyncCtx)
       at System.Threading.QueueUserWorkItemCallback.System.Threading.IThreadPoolWorkItem.ExecuteWorkItem()
       at System.Threading.ThreadPoolWorkQueue.Dispatch()
       at System.Threading._ThreadPoolWaitCallback.PerformWaitCallback()}
  6. Alex Fidanov
    Admin
    Alex Fidanov avatar
    636 posts

    Posted 11 Apr 2011 Link to this post

    Hi Ravindranath,

    We are aware of this issue. It is logged in our PITS here so you can check its progress.

    Regards,
    Alex Fidanov
    the Telerik team
    Do you want to have your say when we set our development plans? Do you want to know when a feature you care about is added or when a bug fixed? Explore the Telerik Public Issue Tracking system and vote to affect the priority of the items
  7. Max
    Max avatar
    1 posts
    Member since:
    Sep 2011

    Posted 07 Sep 2011 Link to this post

    Is there a way to fix this issue?
  8. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 13 Sep 2011 Link to this post

    Hello Max,

     Currently we cannot promise a time-frame when this issue is going to be fixed. Unfortunately, there are no existing workarounds so far.

    Kind regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  9. Yuk
    Yuk avatar
    9 posts
    Member since:
    Aug 2010

    Posted 13 Sep 2011 Link to this post

    We also get the same problem.  All we do is adding parameter

    Can you please fix it? We only try to add a parameter

     

     

     

    <i:Interaction.Triggers>

     

     

     

     

    <i:EventTrigger EventName="FileUploadStarting">

     

     

     

     

    <Mvvm:EventToCommand Command="{Binding Path=FileUploadingCommand}" PassEventArgsToCommand="True"/>

     

     

     

     

    </i:EventTrigger>

     

     

     

     

     

    </i:Interaction.Triggers>

     

     

     

    private ICommand fileUploadingCommand;

     

     

     

     

    public ICommand FileUploadingCommand

     

    {

     

     

    get

     

     

     

     

     

    {

     

     

    if (fileUploadingCommand == null)

     

    {

    fileUploadingCommand =

     

    new Command((par) => true, FileUploadStartExecuting);

     

    }

     

     

    return fileUploadingCommand;

     

    }

     

     

    set { fileUploadingCommand = value; }

     

    }


     

     

     

    private void FileUploadStartExecuting(object obj)

     

    {

     

     

    FileUploadStartingEventArgs fileUploadStartingEventArgs = obj as FileUploadStartingEventArgs;

     

     

     

    if (fileUploadStartingEventArgs!=null)

     

    {

    fileUploadStartingEventArgs.FileParameters.Add(

     

    "myparam", this.myparam);

     

    }

    }

  10. Petar Mladenov
    Admin
    Petar Mladenov avatar
    2891 posts

    Posted 16 Sep 2011 Link to this post

    Hi Yuk,

     This parameter comes from the UserControl(this.myparam) which is UIElement and this leads to the exception. Currently, voting for this issue is the only way to increase its priority since our development to-do list is too big. Thank you for your understanding. 

    Regards,
    Petar Mladenov
    the Telerik team

    Explore the entire Telerik portfolio by downloading the Ultimate Collection trial package. Get it now >>

  11. Andreas
    Andreas avatar
    14 posts
    Member since:
    Feb 2011

    Posted 23 Jan 2013 Link to this post

    Hi Telerik Team!

    We have the same issue with Q3 2012.

    When is this going to be solved?

    Thanks!
  12. Tina Stancheva
    Admin
    Tina Stancheva avatar
    3298 posts

    Posted 25 Jan 2013 Link to this post

    Hello Andreas,

    As I posted in the support ticket you raised, wrapping your FileUploadStaring custom logic in a Dispatcher sometimes helps in getting over the issue. Can you please try this workaround on your side? Let us know if it helps.

    Regards,
    Tina Stancheva
    the Telerik team

    Explore the entire Telerik portfolio by downloading Telerik DevCraft Ultimate.

Back to Top
DevCraft banner