10 Answers, 1 is accepted
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
code used
private void RadUpload_FileUploadStarting(object sender, Telerik.Windows.Controls.FileUploadStartingEventArgs e)
{
e.UploadData.FileName = RenameToAnotherName(e.UploadData.FileName);
} Then i usedprivate 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.
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()}
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
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 >>
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);
}
}
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 >>
We have the same issue with Q3 2012.
When is this going to be solved?
Thanks!
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.
