English 中文(简体)
WPF中的文件上载人
原标题:File uploader in WPF

I m trying to create a custom file upload control in WPF 4.0 and I m stuck in one point.
I m not able to save file in my solution folder after browsing the file. Below code I m using for Browsing

private void btnBrowse_Click(object sender, RoutedEventArgs e)
        {
            // Create OpenFileDialog

            Microsoft.Win32.OpenFileDialog dlg = new Microsoft.Win32.OpenFileDialog();
            dlg.Filter = "Images (*.JPG;*.JPEG;*.PNG)|*.JPG;*.JPEG;*.PNG";
            Nullable<bool> result = dlg.ShowDialog();
            if (result == true)
            {
                string filename = dlg.FileName;
                FileNameTextBox.Text = filename;
            }
        }

 private void btnUpload_Click(object sender, RoutedEventArgs e)
        {

            string filename = FileNameTextBox.Text;
           // Now I want save this file to my image folder.
        }

现在,我想在我的解决方案范围内,在图像夹中保存档案。 伙伴关系。 NET我们使用服务器。 用于绘制特定相对或虚拟途径的地图,供服务器上相应的物理目录使用。 但是,我不相信我们能够在森林小组中为实现同样目标而使用什么。 妇联新增加一米,请帮助我。

最佳回答

如果你谈论世界森林论坛,而不是银灯,那么了解世界森林论坛和伙伴关系之间的区别非常重要。 NET。 ASP. 该网络是吉大港山区议定书的主办平台。 Paths in an ASP. 因特网网址不一定直接在软盘上,即服务器上。 地图绘制为制图业提供了一个途径。 NET走了一条ph路。

另一方面,世界森林论坛是显而易见的,只是一个“倡议”框架。 这不是像伙伴关系这样的东道环境。 NET,因此,测绘路径的概念与世界森林基金无关。 根据你提供的代码,你不是“<>上载<>m>”的档案,你只是开放<>。 在计生联中,你的申请逻辑直接在用户系统上运行,因此可以通过该系统查阅档案系统。 IO namespace. 您可使用FileStream 类别和拷贝从来文方向您的新档案人工复印件,或简单复制“开放式”文档,使用

铭记,由于您的申请是桌面申请,您的申请将受到操作您申请的用户许可的限制。 如果操作你的申请的用户没有获准在磁盘上写某些地方,那么你在试图写字时会遇到例外情况。 如果他们没有许可阅读或删除某些地方的档案,情况也是如此。 确保在用户许可的档案系统领域,如文件夹,进行你进行的任何档案活动。

public void btnUpload_Click(object sender, RoutedEventArgs e)
{
    string filename = FileNameTextBox.Text;
    if (File.Exists(filename))
    {
        // TODO: Show an error message box to user indicating destination file already uploaded
        return;
    }

    string name = Path.GetFileName(filename);
    string destinationFilename = Path.Combine("C:\temp\uploaded files\", name); 

    File.Copy(filename, destinationFilename);

    // TODO: Show information or message box indicating file has copied
}
问题回答

暂无回答




相关问题
WPF convert 2d mouse click into 3d space

I have several geometry meshes in my Viewport3D, these have bounds of (w:1800, h:500, d:25). When a user clicks in the middle of the mesh, I want the Point3D of (900, 500, 25)... How can I achieve ...

Editing a xaml icons or images

Is it possible to edit a xaml icons or images in the expression design or using other tools? Is it possible to import a xaml images (that e.g you have exported) in the expression designer for editing?...

WPF: writing smoke tests using ViewModels

I am considering to write smoke tests for our WPF application. The question that I am faced is: should we use UI automation( or some other technology that creates a UI script), or is it good enough to ...

WPF - MVVM - NHibernate Validation

Im facing a bit of an issue when trying to validate a decimal property on domain object which is bound to a textbox on the view through the viewmodel. I am using NHibernate to decorate my property on ...

How do WPF Markup Extensions raise compile errors?

Certain markup extensions raise compile errors. For example StaticExtension (x:Static) raises a compile error if the referenced class cannot be found. Anyone know the mechanism for this? Is it baked ...

WPF design-time context menu

I am trying to create a custom wpf control, I m wondering how I can add some design-time features. I ve googled and can t seem to get to my goal. So here s my simple question, how can I add an entry ...

How to combine DataTrigger and EventTrigger?

NOTE I have asked the related question (with an accepted answer): How to combine DataTrigger and Trigger? I think I need to combine an EventTrigger and a DataTrigger to achieve what I m after: when ...

热门标签