Click here to Skip to main content
15,890,186 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
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);
}
}
Posted
Updated 3-Aug-17 6:30am
v2

1 solution

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();  
   }  
}
 
Share this answer
 
Comments
Ganesh Kums 4-Aug-17 2:55am    
Its not working

before that I have also an event to stop an bvh file writing.

if (BVHFile != null)
{
BVHFile.closeBVHFile();


BVHFile = null;
StopKinect(sensor);

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900