Vectorlight News

  • Chat App Converted to HTML and JQuery
    Sep 08, 2011

    Converted from Silverlight to HTML and Javascript/JQuery is the Vectorlight Chat App. Login using your Vectorlight password to chat using your username and avatar.

  • HTML5 iPhone,Android Big Guns Tower Defense
    Jul 02, 2011

    Big Guns has made the leap from Windows Phone 7 (XNA) to HTML5 so you can now play it on your iPhone, Android and other HTML5 compatible devices.

  • HTML5 Games - Word Poppers and Batty
    Jun 04, 2011

    As the take-up of HTML5 quickens (74% of users currently have a browser capable of HTML5 Canvas) we present two more games for both your browser and mobile.

  • Big Guns Tower Defense on Windows Phone 7
    May 06, 2011

    Coming soon to Windows Phone 7 is an XNA port of the popular Vectorlight tower defense game Super Tower Defense. Whilst retaining many of the graphical and gameplay features of the original Silverlight game.

  • Wakacube WP7 Update
    Apr 26, 2011

    Released to the Windows Phone 7 marketplace today is Version 1.1 of Wakacube the 3D physics game of skill. Included in the update are more levels (30 in total) and new mode Wakatime which generates random crate structures to keep players entertained long after the levels have been completed.

  • Home Page News
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: 

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