using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpenFileDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace OpenFileDialog
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
private void Form1_Load(object sender, EventArgs e)
{
OpenFileDialog1.FileName=""; //açılacak olan dosya ismi ilk aşamada boş olarak ayarlanıyor
OpenFileDialog1.InitialDirectory="d:\\"; //dosya seçmek için d diski açılıyor
OpenFileDialog1.Filter="Text Dosyaları(*.txt) |*.txt|Adobe Reader()*.pdf |*.pdf"; //seçilecek olan dosyaların uzantıları belirleniyor
OpenFileDialog1.Title="Dosya Aç"; //dosya seçmek için açılan pencerenin başlığı belirleniyor
DialogResult tus=OpenFileDialog1.ShowDialog(); //DialogResult sınıfından nesne türetiliyor
if(tus==DialogResult.Ok) //türetilen nesne altından basılan tuş kontrol ediliyor
{
label1.Text=OpenFileDialog1.SafeFileName; //Label1 'in textine dosyanın adı ve uzantısı gelir
label2.Text=OpenFileDialog1.FileName; //Label2 'nin textine dosyanın yolu,adı ve uzantısı gelir
}
}
}
}
}
}
}
Hiç yorum yok:
Yorum Gönder