日期:2014-05-17  浏览次数:20974 次

接收文件后自动命名及保存到指定文件夹中的问题
                
我想让它自动保存,不要弹窗出来提示保存,
这是我一开始有弹出保存提示的代码
if (arrMsgRec[0] == 1)//表示收到的是文件
                {
                    SaveFileDialog sfd = new SaveFileDialog();
                    if(sfd.ShowDialog(this)==System.Windows.Forms.DialogResult.OK)
          
                    {
                        string fileSavePath=sfd.FileName ;//获得文件保存路径

                        
                        using (FileStream fs=new FileStream (fileSavePath ,FileMode.Create ))
                        {
                            fs.Write (arrMsgRec ,1,length-1);
                            
                            ShowMsg("文件保存成功:"+fileSavePath );
                        }
                    }
                }


然后我修改的是在开头加上
static string fileSavePath = Application.StartupPath + "\\save\\";   //保存至Save文件夹中
这个语句,然后代码修改为
                if (arrMsgRec[0] == 1)//表示收到的是文件
  {
                        
                        using (FileStream fs=new FileStream (fileSavePath ,FileMode.Create ))
                        {
                            fs.Write (arrMsgRec ,1,length-1);
                            
     &n