[英]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.