您现在的位置: 网页制作教程网 >> 网络编程 >> Asp.net 教程 >> ASP.NET 开发技巧 >> 文章正文

ASP.NET中的状态管理(7)

作者:AspCool

来源:ASPCool

热度:

2006-10-21 13:14:38

以下是引用片段:
 Dim fs As FileStream = CType(saveFileDialog1.OpenFile(), FileStream)
  ' Save the Image in the appropriate ImageFormat based upon the
  ' file type selected in the dialog box.
  ' NOTE that the FilterIndex property is one-based.
  Select Case saveFileDialog1.FilterIndex
  Case 1
  Me.button2.Image.Save(fs, ImageFormat.Jpeg)
  
  Case 2
  Me.button2.Image.Save(fs, ImageFormat.Bmp)
  
  Case 3
  Me.button2.Image.Save(fs, ImageFormat.Gif)
  End Select
  
  fs.Close()
  End If
  End Sub
  
  // C#
  // NOTE: You must import the following namespaces:
  // using System.IO;
  // using System.Drawing.Imaging;
  // Without these import statements at the beginning of your code,
  // the code example will not function.
  private void button2_Click(object sender, System.EventArgs e)
  {
  // Display an SaveFileDialog so the user can save the Image
  // assigned to Button2.
  SaveFileDialog saveFileDialog1 = new SaveFileDialog();
  saveFileDialog1.Filter = "JPeg Image*.jpgBitmap Image*.bmpGif 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 != "")
  {
  // Save the Image via a FileStream created by the OpenFile method.
  FileStream fs = (FileStream)saveFileDialog1.OpenFile();
  // Save 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,ImageFormat.Jpeg);
  break;
  
  case 2 :
  this.button2.Image.Save(fs,ImageFormat.Bmp);
  break;
  
  case 3 :
  this.button2.Image.Save(fs,ImageFormat.Gif);
  break;
  }
  
  fs.Close();
  }
  }

关于写入文件流的进一步信息,请参阅 FileStream.BeginWrite 方法。

[1] [2] 下一页

我来说两句:

1分 2分 3分 4分 5分
姓名: *


* 请各位网友遵纪守法并注意语言文明。
网站简介 | 联系方式 | 意见建议 | 版权说明
Copyright © 2007 All rights reserved
滇ICP备06006992号