本文整理汇总了C#中System.Windows.Forms.OpenFileDialog.Dispose方法的典型用法代码示例。如果您正苦于以下问题:C# System.Windows.Forms.OpenFileDialog.Dispose方法的具体用法?C# System.Windows.Forms.OpenFileDialog.Dispose怎么用?C# System.Windows.Forms.OpenFileDialog.Dispose使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类System.Windows.Forms.OpenFileDialog
的用法示例。
在下文中一共展示了System.Windows.Forms.OpenFileDialog.Dispose方法的6个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的C#代码示例。
示例1: AddImageAction
public void AddImageAction()
{
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
dlg.Filter = "Images|*.png;*.gif;*.jpg";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] filePath = dlg.FileNames;
StreamReader sr = new StreamReader(filePath[0]);
BinaryReader read = new BinaryReader(sr.BaseStream);
Pict = read.ReadBytes((int)sr.BaseStream.Length);
}
dlg.Dispose();
}
示例2: AddImageAction
public void AddImageAction()
{
System.Windows.Forms.OpenFileDialog dlg = new System.Windows.Forms.OpenFileDialog();
dlg.Filter = "Images|*.png;*.gif;*.jpg";
if (dlg.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
string[] filePath = dlg.FileNames;
StreamReader sr = new StreamReader(filePath[0]);
BinaryReader read = new BinaryReader(sr.BaseStream);
byte[] Pict = read.ReadBytes((int)sr.BaseStream.Length);
MemoryStream stream = new MemoryStream(Pict);
stream.Position = 0;
BitmapImage bi = new BitmapImage();
bi.BeginInit();
bi.StreamSource = stream;
bi.EndInit();
ImageSource imgsrc = bi;
Image newimg = new Image();
newimg.Source = imgsrc;
ObservableCollection<Image> listimage = new ObservableCollection<Image>();
foreach (Image img in Pictures)
{
listimage.Add(img);
}
listimage.Add(newimg);
Pictures = listimage;
}
dlg.Dispose();
}
示例3: MenuItem_Click_4_1
private void MenuItem_Click_4_1(object sender, RoutedEventArgs e)
{
// 고객 excel로 추가
System.Windows.Forms.OpenFileDialog openFileDialog = new System.Windows.Forms.OpenFileDialog();
openFileDialog.Multiselect = false;
openFileDialog.Filter = "Excel 97-2013|*.xls";
openFileDialog.FilterIndex = 1;
openFileDialog.ShowDialog();
string xlsfilename = openFileDialog.FileName;
if (string.IsNullOrEmpty(xlsfilename))
return;
openFileDialog.Dispose();
DataSet ds = ExcelHelper.OpenExcelDB(xlsfilename);
if (ds != null)
{
if (ds.Tables.Count == 1)
{
foreach (DataRow row in ds.Tables[0].Rows)
{
Customer _customer = new Customer() {
Group_Name = row[0].ToString().Trim(),
Name = row[1].ToString().Trim(),
Company = row[2].ToString().Trim(),
Title = row[3].ToString().Trim(),
Tel = row[4].ToString().Trim(),
Cellular = row[5].ToString().Trim(),
Extension = row[6].ToString().Trim(),
Email = row[7].ToString().Trim(),
Addr = row[8].ToString().Trim()
};
customers.importExcel(_customer);
}
}
}
}
示例4: CustomAction3
public static ActionResult CustomAction3(Session session)
{
System.Windows.Forms.OpenFileDialog openFileDialog = null;
try
{
var thread = new Thread(
() =>
{
using (openFileDialog = new System.Windows.Forms.OpenFileDialog())
openFileDialog.CheckPathExists = true;
openFileDialog.CheckFileExists = true;
openFileDialog.Filter = "Image Files|*.jpg;*.jpeg;*.png;*.bmp;";
openFileDialog.DefaultExt = "*. *";
if (openFileDialog.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
session["IMGPATH"] = openFileDialog.FileName;
}
if (openFileDialog != null)
{
openFileDialog.Dispose();
}
});
thread.SetApartmentState(ApartmentState.STA);
thread.Start();
thread.Join();
}
catch (Exception ex)
{
System.Windows.Forms.MessageBox.Show(ex.ToString());
}
return ActionResult.Success;
}
示例5: OpenProject
/// <summary>
///
/// </summary>
private void OpenProject()
{
SaveChangesOnDemand();
System.Windows.Forms.OpenFileDialog form = new System.Windows.Forms.OpenFileDialog();
form.Filter = "Xml files (*.xml)|*.xml";
form.Multiselect = false;
if (form.ShowDialog() == System.Windows.Forms.DialogResult.OK)
{
LoadFile(form.FileName);
}
form.Dispose();
}
示例6: UploadNewAvatar
private async void UploadNewAvatar(object sender, MouseButtonEventArgs e)
{
var dialog = new System.Windows.Forms.OpenFileDialog
{
DefaultExt = ".png",
InitialDirectory = Environment.SpecialFolder.MyPictures.ToString(),
Title = "Select a new avatar",
Filter = "Image files | *.png; *.jpg; *.bmp"
};
dialog.ShowDialog();
var mimeType = "image/";
if (String.IsNullOrEmpty(dialog.FileName)) return;
if (dialog.SafeFileName == null) return;
if (dialog.SafeFileName.EndsWith(".png")) mimeType += "png";
else if (dialog.SafeFileName.ToLower().EndsWith(".jpg")) mimeType += "jpg";
else if (dialog.SafeFileName.EndsWith(".bmp")) mimeType += "bmp";
else
{
dialog.Dispose();
App.Connection.NotificationController.Notification.Notify("That's not a supported file type! Please try again.");
return;
}
await App.Connection.SessionController.CurrentSession.UploadAvatar(
new FileStream(dialog.FileName, FileMode.Open), mimeType);
dialog.Dispose();
}