获取保存对话框中的C#文件路径 [英] Obtain file path of C# save dialog box

查看:102
本文介绍了获取保存对话框中的C#文件路径的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我有,当我preSS一个按钮,弹出一个保存对话框。但是我不想保存文件在这一点上,我想取的名字,并将其放置在旁边的文本框中的按钮,供稍后使用的名称。

I've got a save dialog box which pops up when i press a button. However i dont want to save a file at that point, i want to take the name and place it in the text box next to the button, for the name to be used later.

谁能告诉我如何从保存对话框中的文件路径后使用它?

Can anybody tell me how to obtain the file path from the save dialog box to use it later?

推荐答案

下面是一个简单的code我只是写速度非常快...相反Console.Write,你可以在道路就是存储在变量并使用它更高版本。

Here is a sample code I just wrote very fast... instead of Console.Write you can simply store the path in a variable and use it later.

SaveFileDialog saveFileDialog1 = new SaveFileDialog(); 
saveFileDialog1.InitialDirectory = Convert.ToString(Environment.SpecialFolder.MyDocuments); 
saveFileDialog1.Filter = "Your extension here (*.EXT)|*.ext|All Files (*.*)|*.*" ; 
saveFileDialog1.FilterIndex = 1; 

if(saveFileDialog1.ShowDialog() == DialogResult.OK) 
{ 
    Console.WriteLine(saveFileDialog1.FileName);//Do what you want here
} 

这篇关于获取保存对话框中的C#文件路径的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆