添加用户选择文件后的提示
我在客户端应用程序中添加了一个打开文件对话框,以便用户可以选择要发送到 Web 服务的特定文件。
然而,文件在选择文件后立即发送,而我希望有一个辅助提示,例如“发送 - '文件名'按钮是。按钮否。”选择文件后弹出。
这样,万一用户选择了错误的文件,他们将有机会看到他们选择了哪个文件。
到目前为止,我有以下代码 -
private void button1_Click(object sender, EventArgs e)
{
//Read txt File
openFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader myReader = new StreamReader(openFileDialog1.FileName);
myReader.Close();
string csv = File.ReadAllText(openFileDialog1.FileName);
我需要在他们选择文件后出现提示,但不知道如何执行此操作,因此任何输入将不胜感激。
I have added an open file dialog box to my client application so that the used can select a specific file they want to send to the web service.
However the file gets sent the moment the file has been selected, whereas I would like to have a secondary prompt e.g. "Send - 'file name' Button Yes. Button No." to pop up after they have selected the file.
This would be incase the user selected the wrong file they would have a chance to see which one they selected.
So far I have the following code -
private void button1_Click(object sender, EventArgs e)
{
//Read txt File
openFileDialog1.Filter = "Text Files (*.txt)|*.txt|All Files (*.*)|*.*";
openFileDialog1.FilterIndex = 1;
if (openFileDialog1.ShowDialog() == DialogResult.OK)
{
StreamReader myReader = new StreamReader(openFileDialog1.FileName);
myReader.Close();
string csv = File.ReadAllText(openFileDialog1.FileName);
I need the prompt to come up after they have selected the file but not sure how to do this so any input would be greatly appreciated.
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
您需要在第一个对话框后手动添加第二个检查:
等等 等等
信息 MessageBox.Show。您可以从此处获取有关可能结果/选项的信息。
您可以通过将消息设置为类似以下内容来确保用户看到要上传的文件:
you need to add the second check manually after the first dialog:
etc etc
Information on MessageBox.Show. You can get information on the possible results/options from here.
You could ensure that the user sees the file to be uploaded by making the message something like:
MessageBox.Show(...) 是您正在寻找的方法。
MessageBox.Show(...) is the method you're looking for.
您可以使用消息框:
You can use a message box:
修改后的代码示例。
A sample of the code modified.