如何使用保存文件对话框保存bvh文件? [英] How to save bvh file using save file dialog?

查看:101
本文介绍了如何使用保存文件对话框保存bvh文件?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

如何使用C#中的按钮使用保存文件对话框保存此bvh文件?



我绝对是编程的初学者。它会自动保存在Bin / release文件夹中。我尝试了很多方法,但我没有找到结果。有人可以帮忙吗?



我尝试了什么:



{

if(BVHFile == null&& sensor!= null)

{





DateTime thisDay = DateTime.Now;

string txtFileName = thisDay.ToString(dd.MM.yyyy_HH.mm);

BVHFile = new writeBVH (txtFileName);

}

}

How can I save this bvh file using save file dialog with button in C#?

And I am absolutely beginner for programming. It is saving automatically in Bin/release folder. I tried a lot ways but I didn't find results. Could anyone help?

What I have tried:

{
if (BVHFile == null && sensor != null)
{


DateTime thisDay = DateTime.Now;
string txtFileName = thisDay.ToString("dd.MM.yyyy_HH.mm");
BVHFile = new writeBVH(txtFileName);
}
}

推荐答案

private void button2_Click(object sender, System.EventArgs e)  
{  
   // Displays a SaveFileDialog so the user can save the Image  
   // assigned to Button2.  
   SaveFileDialog saveFileDialog1 = new SaveFileDialog();  
   saveFileDialog1.Filter = "JPeg Image|*.jpg|Bitmap Image|*.bmp|Gif Image|*.gif";  
   saveFileDialog1.Title = "Save an Image File";  
   saveFileDialog1.ShowDialog();  

   // If the file name is not an empty string open it for saving.  
   if(saveFileDialog1.FileName != "")  
   {  
      // Saves the Image via a FileStream created by the OpenFile method.  
      System.IO.FileStream fs =   
         (System.IO.FileStream)saveFileDialog1.OpenFile();  
      // Saves the Image in the appropriate ImageFormat based upon the  
      // File type selected in the dialog box.  
      // NOTE that the FilterIndex property is one-based.  
      switch(saveFileDialog1.FilterIndex)  
      {  
         case 1 :   
         this.button2.Image.Save(fs,   
            System.Drawing.Imaging.ImageFormat.Jpeg);  
         break;  

         case 2 :   
         this.button2.Image.Save(fs,   
            System.Drawing.Imaging.ImageFormat.Bmp);  
         break;  

         case 3 :   
         this.button2.Image.Save(fs,   
            System.Drawing.Imaging.ImageFormat.Gif);  
         break;  
      }  

   fs.Close();  
   }  
}


这篇关于如何使用保存文件对话框保存bvh文件?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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