Latest News

  • Super Tower Defense Game
    Mar 10, 2010

    New to the games section is the new Super Tower Defense game. Defend your base from the ever advancing army of tanks, buggies...

  • New Rich Text Editor User Control
    Feb 19, 2010

    By popular request, here we present a re-usable User Control containing the Liquid RichTextBox along with the most common formatting functions included.

  • Silverlight 3 Controls V5.2.7 Released
    Feb 19, 2010

    This release includes several fixes for issues raised in the forum. The main improvement is to the RichTextBox which now provides access and methods to the document elements allowing...

  • Super Shoot Em Up Game
    Feb 04, 2010

    Added to the games section is the new Super Shoot 'Em Up game. Take control of a tank with your aim being to blow up your opposing tanks and collect all the powerups.

  • Silverlight 3 Controls V5.2.6 Released
    Feb 04, 2010

    This release includes some minor fixes for several forum posts. Please see the notes on the download page for full details on what has changed.

parseval
parseval
Uploading File from IsolatedStorage or From Stream Posted: Nov 21, 2009
 

Hi,

great work with the fileuploader component!

Anyway I need to upload a file from isolated storage and I don't know how to get the required FileInfo data for the UpdateFile method..


Alternatively I could use the UploadData method that needs a stream but I can't get it working..


I really would apprecciate an example for that.


So many thanks for your great job!


Best regards, Andrea.

 
 
dan
dan
RE: Uploading File from IsolatedStorage or From Stream Posted: Nov 25, 2009
 

Hi Andrea,


You can use the web service provided with the demo code, please download the latest version here, this will recieve your file.  If you have a Stream rather than a FileInfo object, yes, you need to use the UploadData method.


To use the UploadData method you will use:


_uploader.UploadData("myUpload", dialog.File.OpenRead(), dialog.File.Name, target, dialog.File.Name, true, "");


And your web service method stub will be:


public string Upload(string id, string mode, string path, string name, string targetname, string filedata, bool overwrite, string tag, bool final)


Thanks!

 
 
parseval
parseval
RE: Uploading File from IsolatedStorage or From Stream Posted: Nov 25, 2009
 

Hi Dan,

thank you for your time.

Actually the WebMethod Upload I took from your example it never called when I try to invoke it from:


uplUploader.UploadData("myUpload", data, "hello", "target", "hello", true, "");


Notice I have a stream (data) from a memory stream and not from a dialog.

If I used the UploadFiles defining a convenient webmethod all works right. But I have to use the UploadData I guess, because I don't have data source from a user diaog.


I don't know where I'm wrong ...Thank you!


[WebMethod]

    public string Upload(string id, string mode, string path, string name, string targetname, string filedata, bool overwrite, string tag, bool final)

    //public string Upload(string id, string mode, string path, string name, string filedata, bool overwrite, string tag, bool final)

    {

        string filename = string.Empty;


        if (!path.StartsWith("documents/"))

        {

            return "";

        }


        name = System.Text.RegularExpressions.Regex.Replace(name, "[^a-zA-Z0-9 \\-\\._!]", "");

        if (name.EndsWith(".dll") || name.EndsWith(".ascx") || name.EndsWith(".aspx"))

        {

            return "";

        }


        try

        {

            filename = Server.MapPath("~") + @"\" + path.Replace("/", @"\") + name;


            if (mode == "new")

            {

                if (File.Exists(filename) == true)

                {

                    if (overwrite)

                    {

                        File.Delete(filename);

                    }

                    else

                    {

                        return "File Already Exists";

                    }

                }


                WriteFile(filename, Convert.FromBase64String(filedata), FileMode.Create);

            }

            else

            {

                // WriteFile(filename, Convert.FromBase64String(filedata), FileMode.Append);

            }

        }

        catch (Exception ex)

        {

            File.Delete(filename);

            return "File Write Error: " + ex.Message;

        }


        return "ok";

    }

 
 
dan
dan
RE: Uploading File from IsolatedStorage or From Stream Posted: Nov 28, 2009
 

Okay, Passing data from a memory stream rather than the file dialog as in my example will work just the same.  I assume you have placed a breakpoint on your web service when testing and it is never called?


Looking at your web service it looks fine and if it is never called suggests the problem is with this Silverlight client and quite possibly the memory data stream, is it possible for you to post/email your full Silverlight or at least a test application that reproduces the problem?


Thanks!