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

Problem getting File Selected Programmatically

3 Answers 129 Views
Upload
This is a migrated thread and some comments may be shown as answers.
malebo
Top achievements
Rank 1
malebo asked on 30 Mar 2009, 02:21 PM
Hi,

I'm creating  the Uploader control programmatically.

And using FilesSelected event.

The problem  is that i'm unable to access the file fullName inside FilesSelected  event

e.SelectedFiles[0].File.FullName.
 It gives me this error:
+  e.SelectedFiles[0].File.FullName 'e.SelectedFiles[0].File.FullName' threw an exception of type 'System.Security.SecurityException' string {System.Security.SecurityException}

Please help

3 Answers, 1 is accepted

Sort by
0
Ivan
Telerik team
answered on 31 Mar 2009, 07:26 AM
Hello malebo,

Thank you for your interest in the RadUpload control.

About the FullName of uploaded files - there is a reason for this exception. Silverlight cares about the system security. Let us look a bit deeper in the Silverlight code. You are trying to access the FullName property of the FileSystemInfo class but it is marked as "[SecurityCritical]". Bellow is the declaration of this class:

public abstract class FileSystemInfo  
{  
    // Methods  
    [SecurityCritical]  
    protected FileSystemInfo();  
    [SecurityCritical]  
    public abstract void Delete();  
    [SecuritySafeCritical]  
    public void Refresh();  
 
    // Properties  
    public FileAttributes Attributes { [SecurityCritical] get; [SecurityCritical] set; }  
    public DateTime CreationTime { [SecurityCritical] getinternal [SecurityCritical] set; }  
    internal DateTime CreationTimeUtc { [SecurityCritical] get; [SecurityCritical] set; }  
    internal string DisplayPath { getset; }  
    public abstract bool Exists { [SecuritySafeCritical] get; }  
    public string Extension { [SecuritySafeCritical] get; }  
    public virtual string FullName { [SecurityCritical] get; }  
    public DateTime LastAccessTime { [SecurityCritical] getinternal [SecurityCritical] set; }  
    internal DateTime LastAccessTimeUtc { [SecurityCritical] get; [SecurityCritical] set; }  
    public DateTime LastWriteTime { [SecurityCritical] getinternal [SecurityCritical] set; }  
    internal DateTime LastWriteTimeUtc { [SecurityCritical] get; [SecurityCritical] set; }  
    public abstract string Name { [SecuritySafeCritical] get; }  

Hope this information helps.

All the best,
Ivan
the Telerik team

Check out Telerik Trainer , the state of the art learning tool for Telerik products.
0
malebo
Top achievements
Rank 1
answered on 31 Mar 2009, 09:12 AM
I thought as much Thanks for the response.
:-)
0
Moshe Flam
Top achievements
Rank 1
answered on 01 Feb 2010, 02:44 PM
You can catch the file that was set by the user during the OnFileSelectedChange.
(See the web for "preview image client side telerik uploader"... 
 The latest telerik code uses the eventArgs.get_fileInputField().value; )
and store it in a global javascript var. ) Now you have it for further calls to web services.

For codebehind its simply RadUpload1.UploadedFiles[0].Filename;
of course if the UploadedFiles has a count.
Tags
Upload
Asked by
malebo
Top achievements
Rank 1
Answers by
Ivan
Telerik team
malebo
Top achievements
Rank 1
Moshe Flam
Top achievements
Rank 1
Share this question
or