Results 1 to 8 of 8

Thread: OpenFileDialog in SilverLight

  1. #1
    Join Date
    Jan 2010
    Posts
    126

    OpenFileDialog in SilverLight

    Hello,
    I am writing prog C # with Silverlight, a dialog box to download the file, other than 'that I need to get the file name and path to file as a string, the file name but the way I do not know it is not working. Do you have any sample code for this? Any help will be great. Thank you.

  2. #2
    Join Date
    Nov 2009
    Posts
    359

    Re: OpenFileDialog in SilverLight

    Hello,
    Try the following code

    Code:
     OpenFileDialog opfld = new OpenFileDialog();            
                opfld.Multiselect = false;
                opfld.Filter = "All Files |*.*";
     
                if (opfld.ShowDialog() == True)
                (
                    System.IO.FileInfo fl = opfld .File;
                       
                        string fileName = fl.Name;
                        / / Call to the Next Swearing, such as forbidden               
                         d=fl.Directory                          
                        
                )

  3. #3
    Join Date
    Dec 2009
    Posts
    211

    Re: OpenFileDialog in SilverLight

    I have changed the above code and this is in more advanced form.
    Code:
    OpenFileDialog opfld = new OpenFileDialog();            
                opfld.Multiselect = false;
                opfld.Filter = "All Files |*.*";
     
                if (opfld.ShowDialog() == DialogResult.OK)
                (
                    / / fl path
                    string path = opfld.FileName;    
                )

  4. #4
    Join Date
    Jan 2010
    Posts
    126

    Re: OpenFileDialog in SilverLight

    Code:
     / / File path
    string path = OFD.FileName;
    I had tried, but alas not want it so, in Silverlight at OpenFileDialog no property FileName, there is only ofd.File.Name but it gives me only a name, but I need a way. Thank you

  5. #5
    Join Date
    Mar 2010
    Posts
    383

    Re: OpenFileDialog in SilverLight

    Here's an example correctly, the OpenFileDialog in Silverlight (build System.Windows.Controls, namespace System.Windows.Controls)

    Code:
    OpenFileDialog Dialog = new OpenFileDialog();
    But it is theoretically possible to obtain the directory path, because it marked attribute. Critical security, ie the code to compile, BUT will Not work (in Silverlight is Not Allowed), BUT it will work for WPF-Applications

    Code:
    DirectoryInfo dirInfo = Dialog.File.Directory;
    string nameInfo = Dialog.File.DirectoryName;

  6. #6
    Join Date
    Aug 2010
    Posts
    40

    Re: OpenFileDialog in SilverLight

    via JavaScript and I got this way, but this does not help to solve the main problem - I need to copy the file to the server ... CAN this be done Via JScript? Silverlight markups below do Not allow to do with the files ....

  7. #7
    Join Date
    Nov 2009
    Posts
    359

    Re: OpenFileDialog in SilverLight

    Silverlight application runs in the sandbox .. Just got the name and path you do not do it. In-class dialog to open a file must be property in which remains something like FileStream (file stream). Reads its contents and sends it to server. Or, once more through ActiveX and JavaScript

  8. #8
    Join Date
    Aug 2010
    Posts
    38

    Re: OpenFileDialog in SilverLight

    The same applies to the conservation .. You open a dialogue - it is an addition, dialogue, save more and asking the user to bypass the security system for a specific individual file. Therefore, the class file dialogue in SL modified so that you do not get the file path, but you get access to it through a copy of the file dialog. They took from it a file stream and write-read. The user you solved it, by clicking on OK in the dialog.

Similar Threads

  1. Silverlight 5 released; will there be a Silverlight 6?
    By GopuHD in forum Windows Software
    Replies: 4
    Last Post: 11-01-2012, 02:28 PM
  2. Replies: 5
    Last Post: 28-04-2011, 10:27 AM
  3. Replies: 3
    Last Post: 17-04-2011, 04:55 PM
  4. Replies: 2
    Last Post: 09-08-2010, 09:41 AM
  5. What is SilverLight?
    By Champak in forum Windows Software
    Replies: 4
    Last Post: 31-01-2009, 10:21 AM

Tags for this Thread

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Page generated in 1,713,956,524.73950 seconds with 16 queries