简体   繁体   English

在用户本地计算机上下载并保存xml文件

[英]Download and save xml file on user local machine

On my application I have a button used to save save an xlm file on specific uri indicated on my code. 在我的应用程序上,我有一个用于将xlm文件保存到代码上指示的特定uri上的按钮。 but I would like to give the user the possibility to save this file where he wants. 但我想让用户可以将此文件保存在他想要的位置。

page.xaml page.xaml

page.cs page.cs

private void Bt_Export_Click(object sender, RoutedEventArgs e)
        {
            CIRCUIT _selectedCircuit = (CIRCUIT)Lb_Circuits.SelectedItem;
            busyIndicator.IsBusy = true;

            this.DBContext.SaveXmlFile(_selectedCircuit.CIR_CIRCUIT, _action =>
            {
                if (!_action.HasError)
                {

                }
                busyIndicator.IsBusy = false;
            }, null);

        }

//

public void SaveXmlFile(string XMlString)
        {
            XmlDocument XmlCircuit = new XmlDocument();
            XmlCircuit.LoadXml(XMlString);          
            XmlCircuit.Save("C:/Users/izdoudou/Ciruit" + DateTime.Now.Date.ToString("yyMMddHHmm") + ".xml");
            string ts= XmlCircuit.BaseURI;
        }

Could you tell me if it is possible integrate this functionnality with silverlight, and how can I do it? 您能否告诉我是否有可能将此功能与Silverlight集成在一起,我该怎么做?

Kind regards, 亲切的问候,

You can use a FolderBrowserDialog for the purpose. 您可以为此使用FolderBrowserDialog

string foldername=@"C:\Users\izdoudou\Ciruit";    
DialogResult result = folderBrowserDialog1.ShowDialog();
            if( result == DialogResult.OK )
            {
                folderName = folderBrowserDialog1.SelectedPath;

            }

In your code change 在您的代码更改中

XmlCircuit.Save("C:/Users/izdoudou/Ciruit" + DateTime.Now.Date.ToString("yyMMddHHmm") + ".xml");

to

XmlCircuit.Save(foldername +"\\\\"+ DateTime.Now.Date.ToString("yyMMddHHmm") + ".xml");

Hope it helps. 希望能帮助到你。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 使用.net核心API将XML文件下载到本地计算机 - Download XML file using .net core API to local machine 从服务器下载.xml文件并保存到Windows Mobile 6.5 .net Compact Framework中的本地存储中 - download .xml file from server and save to local storage in windows mobile 6.5 .net compact framework 如何在组合框中选择的本地计算机中下载文件? - How to download file in local machine which is selected in combo box? 将Docx文件从本地服务器计算机下载到客户端? - Download Docx file from local server machine to client? 如何将 aspx 文件另存为 html 文件和文件夹到本地计算机或服务器 - how to save aspx file as html file and folder to local machine or server 如何让用户下载 xml 文件 - How to let the user to download an xml file 保存图片 <notesbitmap> dxl文件中的文件到本地计算机,c# - save image from <notesbitmap> in dxl file to local machine , c# 将字节下载为原始文件格式,然后保存到本地驱动器 - Download a byte to its original file format, and save to local drive 将页面下载为pdf文件并保存在C#的本地文件夹中 - to download a page as pdf file and save in a local folder in C# asp.net允许用户使用“保存”对话框下载文件 - asp.net let user download file with save dialog
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM