Problem getting File Selected Programmatically

4 posts, 0 answers
  1. malebo
    malebo avatar
    7 posts
    Member since:
    Feb 2009

    Posted 30 Mar 2009 Link to this post

    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

  2. Ivan
    Admin
    Ivan avatar
    519 posts

    Posted 31 Mar 2009 Link to this post

    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.
  3. DevCraft banner
  4. malebo
    malebo avatar
    7 posts
    Member since:
    Feb 2009

    Posted 31 Mar 2009 Link to this post

    I thought as much Thanks for the response.
    :-)
  5. Moshe Flam
    Moshe Flam avatar
    1 posts
    Member since:
    Oct 2009

    Posted 01 Feb 2010 Link to this post

    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.
Back to Top