Latest News

  • Silverlight Online Chat
    Jul 24, 2010

    Today we launch the new Silverlight Live Chat application demonstrating the Liquid RichTextBox and Emoticon replacements.

  • New Super Shoot Em Up 2 Game
    Jun 29, 2010

    Added to the Games section is the new Super Shoot 'Em Up 2 game. Take control of your tank with the aim to defeat the computer controlled opponents. Features all new weapons, levels and Battle Mode!

  • Silverlight 4 Controls V5.3.2 Released
    Jun 28, 2010

    This release contains several fixes raised in the forums.

  • New Sandmania Puzzle Game
    Jun 18, 2010

    Sandmania is the latest game from vectorlight, the aim of this game is to guide sand from the top of the screen to the various colored containers below.

  • New Moon Tower Defense Game
    May 29, 2010

    Added to the Games section is the new Moon Tower Defense game. Defend the Moon from the circling Aliens and Humans.

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!

 
 

Rate this page: 

1 Star 2 Star 3 Star 4 Star 5 Star
8 Ratings / 2.5 Average