开发者

OpenFile dialog, Multiselect=true, i cannot reach files

开发者 https://www.devze.com 2023-01-26 06:50 出处:网络
private void btnNew_Click(object sender, System.Windows.RoutedEventArgs e) { OpenFileDialog of = new OpenFileDialog();
private void btnNew_Click(object sender, System.Windows.RoutedEventArgs e)
{        
    OpenFileDialog of = new OpenFileDialog();
    of.Multiselect = true;
    of.Filter = "JPG Dosyaları|*.jpg|JPEG Dosyaları|*.jpeg";
    of.ShowDialog();
    foreach (var file in of.Files)
    {
        MessageBox.Show(file.FullName);
    }
}

The problem is i want to open multiple开发者_运维技巧 files' in Silverlight and i don't know any other way doing it than passing the filenames into a foreach loop. The problem is Silverlight don't like if i try to reach files in a loop, it must be a direct command from user. In this case it throws an exception:

File operation not permitted

So is there another way manipulating local files (not from isolated space), or is there any way i can make this code work? Thanks guys.


Don't use file.FullName to open the file. You get a FileInfo object back, use one of its OpenXxxx() methods to open the file.

0

精彩评论

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