tags:

views:

260

answers:

1

Hi

Im trying to clone facebook image uploader which is built in java. But I would like to use silverlight so Im wondering if I can somehow read local directory.

If I have this running an some remote server I can easily read the content of that server as I have C# as backend. But Im not sure how could I read certain directory of the user which is using silverlight application.

Any ideas if this is possible or not?

+4  A: 

It's possible to read file "blindly" using OpenFileDialog. Blindly means you can let the user point the dialog to the file so Silverlight can read its content but it can't tell where the file is located.

Example:

var fileDialog = new OpenFileDialog();
var dialog = fileDialog.ShowDialog();
if (dialog.HasValue && dialog.Value)
{
    byte[] bytes;
    using (var fileReader = fileDialog.File.OpenRead())
    {
        bytes = new byte[fileReader.Length];
        fileReader.Read(bytes, 0, (int) fileReader.Length);
    }
}

The access to the file system is limited for security. Some access (blind as well) can be done using Isolated Storage where you can store data and access later.

Elisha