开发者

Visual C# 2008 Control to set a path

Greeti开发者_Python百科ngs,

What control in Visual C# 2008 would allow me to set a path and get the value of that path.

For example: I want the user to click a button then select a path where he/she would do the operation such as save a file in selected path.


You want to use a FolderBrowserDiaglog

var folderBrowserDiaglog = new FolderBrowserDiaglog();
if ( folderBrowserDiaglog.ShowDialog() == DialogResult.OK )
{
  string path = folderBrowserDiaglog.SelectedPath;
}


I don't mean to repeat, but none of the other answers seemed to be exactly what you wanted.

There are 3 controls: FolderBrowserDialog, OpenFileDialog, and SaveFileDialog. There names are pretty intuitive. You use all 3 the same way. Tanascius has a good example in his post. The folder dialog you would use if you want the user to select a whole folder to look at. The open you would use if you want the user to select one or many files to open. Save is the same as open, but you would use it when saving a file out.

Hope this helps.


The FolderBrowse Dialog....


SaveFileDialog (for a file) or FolderBrowserDialog (for a folder). Located in the dialogs tab in the toolbox.


Assuming Windows Forms, try the OpenFileDialog. All common dialogs descend from CommonDialog, so looking at the descendents of that class may help, too.

0

上一篇:

下一篇:

精彩评论

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

最新问答

问答排行榜