开发者

Silverlight and reading local directory

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开发者_JS百科 I read certain directory of the user which is using silverlight application.

Any ideas if this is possible or not?


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.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜