Results 1 to 9 of 9

Thread: Can silverlight 4 used to save or open a file?

  1. #1
    Join Date
    Jul 2009
    Posts
    56

    Can silverlight 4 used to save or open a file?

    I want to convert the file online similar to word to pdf or from pdf to word. Not only that I want to save it on local system of user. I know to do it in the other programming language that I have used but the problem is that I want to this thing through the use of SilverLight 4. In short I want to know can silverlight 4 used to save or open a file, if the answer is yes then I would like to know about it.

  2. #2
    Join Date
    Oct 2005
    Posts
    2,393

    Re: Can silverlight 4 used to save or open a file?

    At the time of running the Elevated Permissions on the Sliverlight 4 application then you can read or write to the local file system. I mean that if you want to get the path for my document then you can get that. For doing this you can use this code: Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments) There are many examples available on net for displaying the local file system in the Tree view environment.

  3. #3
    Join Date
    May 2008
    Posts
    2,389

    Re: Can silverlight 4 used to save or open a file?

    If you want to save the file then you can use the SaveFileDialog Class for that purpose. This option will give the user a dialog box that will enables the user for specify the options for saving the file. For the purpose of declaration you need to use “Public NotInheritable Class SaveFileDialog” and for usage you need you use “Dim instance As SaveFileDialog” I hope this will solve your problem, if you require the code for that purpose then you need to specify the language you are going to use.

  4. #4
    Join Date
    Feb 2008
    Posts
    1,852

    Re: Can silverlight 4 used to save or open a file?

    As far as I know for the purpose of security the Silverlight file and also the print dialogs is necessary to be initiated by the user. I mean to say that this dialog should appear if the user desires for that, by click any button or link. If you are going to use this dialog then you must keep in mind that it should time allotted, means that there should be a time limit on the time allowed between the user initiates for the dialog box and the dialog box is displayed to the user.

  5. #5
    Join Date
    Jan 2008
    Posts
    1,521

    Re: Can silverlight 4 used to save or open a file?

    If you are going to use this saving dialog then I will strongly advise you to use filter for this dialog box through the use of filter property. But if you do not want to use that thing then you will need to set the default file name extension for the files that can be saved through the dialog box, and this can be done through the use of DefaultExt property. You just need to search for that if you want to implement.

  6. #6
    Join Date
    Apr 2008
    Posts
    1,948

    Re: Can silverlight 4 used to save or open a file?

    From the above replies it is clear that you can use silverlight for the purpose of saving the file. But I will like to bring your notice that this silverlight plug-in will not support the SaveFileDialog if you are planning to use this in full screen mode. If you want to avoid this problem then you need to exit the full screen mode before you start to use these classes. I hope that this will be helpful to you. If you want to get more information about this thing then you can reply back with the complete details of your code.

  7. #7
    Join Date
    Feb 2010
    Posts
    766

    Re: Can silverlight 4 used to save or open a file?

    Here is the simple snippet of code in C# that can be used for getting the save dialog box.
    Code:
    SaveFileDialog td;
    public Page()
    {
        InitializeComponent();
        td = new SaveFileDialog();
        td.Filter = "Text Files | *.txt";
        td.DefaultExt = "txt";
     }
    
    private void SaveButton_Click(object sender, RoutedEventArgs e)
    {
        bool? result = td.ShowDialog();
        if (result == true)
        {
            System.IO.Stream fs = td.OpenFile();
            System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
            sw.WriteLine("This can be used for writing something.");
            sw.Flush();
            sw.Close();
        }
    }
    I hope that this will help you.

  8. #8
    Join Date
    Aug 2011
    Posts
    1

    Exclamation Re: Can silverlight 4 used to save or open a file?

    This code works fine... but do you know how to avoid the save dialog every single time that you hit save???. at means, you open the dialog once for create the file... and then continue save will be updates... so you don't need show up the save dialog again??? any ideas??? maybe by reflexion, we can extract the filename from td (dialog) but I am not sure ????

    Quote Originally Posted by Mrigankasekhar View Post
    Here is the simple snippet of code in C# that can be used for getting the save dialog box.
    Code:
    SaveFileDialog td;
    public Page()
    {
        InitializeComponent();
        td = new SaveFileDialog();
        td.Filter = "Text Files | *.txt";
        td.DefaultExt = "txt";
     }
    
    private void SaveButton_Click(object sender, RoutedEventArgs e)
    {
        bool? result = td.ShowDialog();
        if (result == true)
        {
            System.IO.Stream fs = td.OpenFile();
            System.IO.StreamWriter sw = new System.IO.StreamWriter(fs);
            sw.WriteLine("This can be used for writing something.");
            sw.Flush();
            sw.Close();
        }
    }
    I hope that this will help you.

  9. #9
    Join Date
    Dec 2007
    Posts
    2,291

    Re: Can silverlight 4 used to save or open a file?

    I think that the Silverlight plug-in does not support SaveFileDialog in full-screen mode. In most cases, displaying the dialog box in full-screen mode will cause the plug-in to revert to embedded mode. However, to avoid issues on some browsers, you should exit full-screen mode before using these classes. Check here for more information - http://msdn.microsoft.com/en-us/libr...og(VS.96).aspx

Similar Threads

  1. Default view in Open / Save as File Dialog Box
    By Charlie R in forum Windows XP Support
    Replies: 4
    Last Post: 18-03-2011, 05:56 PM
  2. Very slow File Open/Save Dialog
    By PatrModer in forum MS Office Support
    Replies: 6
    Last Post: 08-11-2010, 06:27 PM
  3. File Open/Save Dialog not responding
    By AliilA in forum Vista Help
    Replies: 7
    Last Post: 27-04-2010, 06:06 PM
  4. Open Excel file and save as .xlsx using VB code
    By Bisujaksha in forum Software Development
    Replies: 3
    Last Post: 11-06-2009, 08:06 PM
  5. Mozilla freezes on file save/open
    By fastrod in forum Technology & Internet
    Replies: 4
    Last Post: 27-01-2009, 11:41 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,513,331.29051 seconds with 17 queries