您可以一个接一个地提示多个saveas对话框吗? [英] Can you prompt multiple saveas dialogue boxes, one after another?

查看:109
本文介绍了您可以一个接一个地提示多个saveas对话框吗?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要能够提示用户保存应用程序刚创建的所有文件.

1.是否可以依次为每个文件提示另存为框?
2.如果没有,您认为一个好的解决方法是什么?

谢谢.

I am needing the ability to prompt the user to save all the files that have just been created by the application.

1. Is it possible to prompt saveas boxes sequentially for each file?
2. If not, what would you suggest a good work around would be?

Thank you.

List<string> convertedFiles = new List<string>();
                 string newFile = "";
                 string convertedFileName = "";
                 foreach (var Agencynumber in agencyfile)
                 {
                     convertedFileName = Agencynumber + "-Authorize.Net - " + date1 + " @ " + date2 + ".ach";
                     newFile = "C:\\authorize.netTEST\\" + Agencynumber + "-Authorize.Net - " + date1 + " @ " + date2 + ".ach";
                     //Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.DesktopDirectory), convertedFileName);

                     StreamWriter sw2 = new StreamWriter(newFile, true);
                     foreach (DataRow dr in dt.Rows)
                     {
                         if (dr[12].ToString().Contains(Agencynumber + "|"))
                         {
                             if (dr[0].ToString() != "2")
                             {
                                 if (dr[9].ToString() != "Total Amount")
                                 {
                                     sw2.Write("6                            ");
                                     sw2.Write(dr[9].ToString().Replace(".", "").Replace(",", "").PadLeft(10, ''0''));
                                     sw2.Write((dr[12].ToString().Replace(Agencynumber + "|", "")).PadRight(15, '' ''));
                                     sw2.Write((dr[13].ToString() + " " + dr[14].ToString()).PadRight(40));
                                     sw2.Write(sw2.NewLine);
                                 }
                             }
                         }
                     }
                     sw2.Write("9");
                     sw2.Write(sw2.NewLine);
                     sw2.Close();
                     convertedFiles.Insert(convertedFiles.Count, newFile);
                }
                 foreach (string newfile in convertedFiles)
                 {
                     SaveFileDialog saveFileDialog1 = new SaveFileDialog();
                     saveFileDialog1.Filter = "txt files (*.ach)|*.ach|All files (*.*)|*.*";
                     saveFileDialog1.DefaultExt = "ach";
                     saveFileDialog1.FilterIndex = 2;
                     saveFileDialog1.InitialDirectory = @"C:\";
                     if (saveFileDialog1.ShowDialog() == DialogResult.OK)
                     {

                     }
                 }



好的,我稍微更改了代码,并为每个创建的文件获取了一个savefile对话框.但是,savefile对话框的文件名"字段中没有文件.



Ok, I have changed my code a bit and am getting a savefiledialog for each file created. However, there is no file in the "File name" field of the savefiledialog. How do I get my created files into the field so they can be saved?

推荐答案

是的,您可以提示用户输入每个文件的保存位置.列表.他们可能恨您,但您可以做到.一种方法是将文件列表放入foreach循环中,然后将保存对话框放入循环中.然后,将提示您列表中的每个文件.
Yes, you can prompt the user for the save location of each file you have in the list. They may hate you, but you can do it. One way to do this would be to put the list of files into a foreach loop and put the save dialog inside the loop. Then, you would get a prompt for each file in your list.


一个更好的选择是让用户选择一个文件夹
A better alternative may be to have the user choose a folder (Folder Browser Dialog)[^] and then save the files using set names.
Your names could be hard coded or configurable through the application or maybe just an external XML.

I think your users whould be much happier.
Also this tends to make more sence in bulk saves as the files are actually tied together so having them all in a folder with consitent naming to a previous save makes sense IMO.


这篇关于您可以一个接一个地提示多个saveas对话框吗?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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