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

How Can I change FileName in The Target Folder

10 Answers 93 Views
Upload
This is a migrated thread and some comments may be shown as answers.
Ahmed
Top achievements
Rank 1
Ahmed asked on 01 Jan 2011, 04:09 PM
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

10 Answers, 1 is accepted

Sort by
0
Tina Stancheva
Telerik team
answered on 03 Jan 2011, 03:47 PM
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
0
Angie
Top achievements
Rank 1
answered on 05 Apr 2011, 08:48 PM
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.
      
0
Angie
Top achievements
Rank 1
answered on 06 Apr 2011, 03:00 PM
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()}
0
Alex Fidanov
Telerik team
answered on 11 Apr 2011, 08:49 AM
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
0
Max
Top achievements
Rank 1
answered on 07 Sep 2011, 09:52 PM
Is there a way to fix this issue?
0
Petar Mladenov
Telerik team
answered on 13 Sep 2011, 09:51 AM
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 >>

0
Yuk
Top achievements
Rank 1
answered on 13 Sep 2011, 11:55 AM
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);

 

}

}

0
Petar Mladenov
Telerik team
answered on 16 Sep 2011, 01:47 PM
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 >>

0
Andreas
Top achievements
Rank 1
answered on 23 Jan 2013, 06:38 AM
Hi Telerik Team!

We have the same issue with Q3 2012.

When is this going to be solved?

Thanks!
0
Tina Stancheva
Telerik team
answered on 25 Jan 2013, 04:28 PM
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.

Tags
Upload
Asked by
Ahmed
Top achievements
Rank 1
Answers by
Tina Stancheva
Telerik team
Angie
Top achievements
Rank 1
Alex Fidanov
Telerik team
Max
Top achievements
Rank 1
Petar Mladenov
Telerik team
Yuk
Top achievements
Rank 1
Andreas
Top achievements
Rank 1
Share this question
or