Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 7040633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T01:56:29+00:00 2026-05-28T01:56:29+00:00

I need to update a file which is on a remote server, using Silverlight

  • 0

I need to update a file which is on a remote server, using Silverlight and C#.
I created the file on the current machine and after that I tried to upload it using this example. It returned no error, but it doesn’t upload my file either.

Could you help me?

this is the ashx code

<%@ WebHandler Language="C#" Class="receiver" %>

using System;
using System.Web;
using System.IO;

public class receiver : IHttpHandler {

   public void ProcessRequest (HttpContext context) {
    string filename = context.Request.QueryString["DB.xml"].ToString();

    using (FileStream fs = File.Create(context.Server.MapPath("~/CLientBin" + filename)))
    {
        SaveFile(context.Request.InputStream, fs);
    }
}

private void SaveFile(Stream stream, FileStream fs)
{
    byte[] buffer = new byte[4096];
    int bytesRead;
    while ((bytesRead = stream.Read(buffer, 0, buffer.Length)) != 0)
    {
        fs.Write(buffer, 0, bytesRead);
    }

}

public bool IsReusable {
    get {
        return false;
    }
 }
}

and this is the c# code:

        OpenFileDialog dlg = new OpenFileDialog();
        dlg.Multiselect = false;
        dlg.Filter = "All files (*.*)|*.*|PNG Images (*.png)|*.png";

        bool? retval = dlg.ShowDialog();

        if (retval != null && retval == true)
        {
            try
            {
                UploadFile(dlg.File.Name, dlg.File.OpenRead());
                titlu.Text = dlg.File.Name;
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.ToString());
            }
        }
        else
        {
            titlu.Text = "No file selected...";
        }
    }

    private void UploadFile(string fileName, Stream data)
    {
        UriBuilder ub = new UriBuilder("http://ganduri.elementfx.com/Handler.ashx");
        ub.Query = string.Format("filename={0}", fileName);

        WebClient c = new WebClient();
        c.OpenWriteCompleted += (sender, e) =>
        {
            PushData(data, e.Result);
            e.Result.Close();
            data.Close();
        };
        c.OpenWriteAsync(ub.Uri);
    }

    private void PushData(Stream input, Stream output)
    {
        byte[] buffer = new byte[4096];
        int bytesRead;

        while ((bytesRead = input.Read(buffer, 0, buffer.Length)) != 0)
        {
            output.Write(buffer, 0, bytesRead);
        }
        MessageBox.Show("Writed");
    }

I have also checked the permissions to the ClientBin folder and are read/write permissions
When I run this code it shows me the “Writed” messageBox, but if I look in the server, the file isn’t anywhere.
I have set a breakpoint in af ashx file functions and id doesn’t reach any of them.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-28T01:56:30+00:00Added an answer on May 28, 2026 at 1:56 am

    Think you need check upload folder for existence, and write access rights

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

i have xml file which contains CDATA i need to update the CDATA as
I need to be able to update my config file programmatically and change my
UPDATED See post #3 below. There is a need to upload a file to
I need to update a field (which is currently empty) based on a match
We are using Maven to compile our project on a build server. We update
In my flash, the socket server returns some xml data that I need to
I'm using a PHP script to stream a live video (i.e. a file which
I have a large file, with 1.8 million rows of data, that I need
How can I create a directory on a remote server using .NET? Both servers
I've got an Access 2007 database that I developed which connects to SQL Server

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.