• SDN Forum üyelikleri çok yakında yeniden açılıyor. Siz de bu büyük topluluğun bir parçası olmak için bizi takipte kalın, gelişmeleri kaçırmayın!

Office İşlemleri

OnurSorhan

Doçent
Katılım
17 Temmuz 2012
Mesajlar
808
Reaksiyon puanı
0
Puanları
16
Merhaba Arkadaşlar
Office Document Files|*.doc;*.docx;*.docm;*.dot;*.dotx;*.xls;*.xlsx;*.xlsm;*.xlsb;*.xla;*.xlam;*.ppt;*.pptx;*.pptm;*.vsd

Bu Üsteki Dosya Türlerini Nasıl Bir İf Yapısı Kurarak Aşadaki Gibi Yazabilirim

if (SelectedFileInfo.Extension == ".doc" || SelectedFileInfo.Extension == ".docx")
 

muratgurcemal

Asistan
Katılım
11 Ağustos 2008
Mesajlar
174
Reaksiyon puanı
0
Puanları
16
Soruyu pek anlamadım ama şu şekilde yapılabilir.

if ("*.doc;*.docx;*.docm;*.dot;*.dotx;*.xls;*.xls x;*.xlsm;*.xlsb;*.xla;*.xlam;*.ppt;*.pptx;*.pptm;* .vsd".IndexOf(SelectedFileInfo.Extension) > -1)
{
//Office Document Files
}
 

kizanlik

Asistan
Katılım
25 Mart 2012
Mesajlar
250
Reaksiyon puanı
0
Puanları
0
if yerine switch kullanmanızı tavsiye ederim:

Kod:
switch SelectedFileInfo.Extension:
{
    case ".doc":   <--| .doc ve .docx uzantısına sahip dosyalar 
    case ".docx":  <--| için aynı işlemi yapabilirsin.
    {
        ...

        break;
    }

    case ".xls:
    {
        ...

        break;
    }
}
 

OnurSorhan

Doçent
Katılım
17 Temmuz 2012
Mesajlar
808
Reaksiyon puanı
0
Puanları
16
if (SelectedFileInfo.Extension == ".doc" || SelectedFileInfo.Extension == ".docx" || SelectedFileInfo.Extension == ".docm" || SelectedFileInfo.Extension == ".dot" || SelectedFileInfo.Extension == ".dotx" || SelectedFileInfo.Extension == ".xls" || SelectedFileInfo.Extension == ".xlsx" || SelectedFileInfo.Extension == ".xlsm" || SelectedFileInfo.Extension == ".xlsb" || SelectedFileInfo.Extension == ".xla" || SelectedFileInfo.Extension == ".xlam" || SelectedFileInfo.Extension == ".ppt" || SelectedFileInfo.Extension == ".pptx" || SelectedFileInfo.Extension == ".pptm" || SelectedFileInfo.Extension == ".vsd" || SelectedFileInfo.Extension == ".mpp")
{

Ben Böyle Yapmışdım :)
 

kizanlik

Asistan
Katılım
25 Mart 2012
Mesajlar
250
Reaksiyon puanı
0
Puanları
0
O zaman soyle de yapabilirsin:

OpenFileDialog.Filter = "Office Files|*.doc;*.docx;*.xls;...";

sadece acilabilecek dosyalarin isimlerini goruntulemeni saglar.

Acilan dosya, filtrede belirtilen extensiona sahip olacagindan soyle devam edebilirsin:

if (OpenFileDialog.ShowDialog() == true)
{
...
 

OnurSorhan

Doçent
Katılım
17 Temmuz 2012
Mesajlar
808
Reaksiyon puanı
0
Puanları
16
OpenFileDialog'a Gerek Yok Projemde
Windows Explorer Uygulaması yapıorum Yazdığım Kodlar işe yaradı yinede tşkr ederim yardımlar için

if (SelectedFileInfo.Extension == ".doc" || SelectedFileInfo.Extension == ".docx" || SelectedFileInfo.Extension == ".docm" || SelectedFileInfo.Extension == ".dot" || SelectedFileInfo.Extension == ".dotx" || SelectedFileInfo.Extension == ".xls" || SelectedFileInfo.Extension == ".xlsx" || SelectedFileInfo.Extension == ".xlsm" || SelectedFileInfo.Extension == ".xlsb" || SelectedFileInfo.Extension == ".xla" || SelectedFileInfo.Extension == ".xlam" || SelectedFileInfo.Extension == ".ppt" || SelectedFileInfo.Extension == ".pptx" || SelectedFileInfo.Extension == ".pptm" || SelectedFileInfo.Extension == ".vsd" || SelectedFileInfo.Extension == ".mpp")
{
DSOFile.OleDocumentProperties doc = new DSOFile.OleDocumentProperties();
doc.Open(SelectedFileInfo.FullName, false, DSOFile.dsoFileOpenOptions.dsoOptionDefault);
// seçilen .doc veya .docx ise dataGridview'e yazılacak özellikler tanımlanır ve eklenir, kaydedilir ve çıkılır
dataGridView1.Rows.Clear();


DataGridViewRow row = new DataGridViewRow();
row.CreateCells(dataGridView1);
row.Cells[0].Value = "Konu";
row.Cells[0].ReadOnly = true;
row.Cells[1].Value = doc.SummaryProperties.Subject;
dataGridView1.Rows.Add(row);

row = new DataGridViewRow();
row.CreateCells(dataGridView1);
row.Cells[0].Value = "Kategorisi";
row.Cells[0].ReadOnly = true;
row.Cells[1].Value = doc.SummaryProperties.Category;
dataGridView1.Rows.Add(row);

row = new DataGridViewRow();
row.CreateCells(dataGridView1);
row.Cells[0].Value = "Yazar";
row.Cells[0].ReadOnly = true;
row.Cells[1].Value = doc.SummaryProperties.Author;
dataGridView1.Rows.Add(row);
 
Üst