0

在我的 silverlight 应用程序中,我希望能够从 OpenFileDialog 窗口中选择一个文件并将其上传/复制到我的 Silverlight 项目中的本地文件夹。我已经能够设置 OpenFileDialog 窗口并为其设置一些选项,但不幸的是我找不到创建文件流然后将其复制到本地文件夹的方法。

private void Change_Avatar_Button_Click(object sender, RoutedEventArgs e)
    {
        OpenFileDialog openfile = new OpenFileDialog();
        openfile.Multiselect = false;
        openfile.Filter = "Images files (*.bmp, *.png)|*.bmp;*.png";

        if ((bool)openfile.ShowDialog())
        {

        }
    }

我试过在网上查看很多教程,但他们似乎只是将文件直接发送到 silverlight 中的 UploadFile 方法,这是我目前不想做的。

谢谢你,以弗所。

4

1 回答 1

1

You can't just write files to local folders without prompting the user a second time (e.g. save as dialog http://www.silverlightshow.net/items/Using-the-SaveFileDialog-in-Silverlight-3.aspx)

You could write it to isolated storage instead: http://blogs.silverlight.net/blogs/msnow/archive/2009/05/21/71909.aspx.

If you want specific examples (e.g. going straight from OpenFileDialog to Isolated storage) I strongly recommend you use Google. The first match on "silverlight openfiledialog to isolated storage" is this: http://forums.silverlight.net/forums/t/201362.aspx

于 2010-09-16T08:25:29.790 回答