İçeriğe geç
ShiftDelete.Net
Haber ara/ SDN'ye SorGiriş
Haber Akışı SDNTV İnceleme Forum Yapay Zeka Akıllı Telefon Elektrikli Otomobil Oyun ShiftDelete.Net Global Teknoloji Haberleri Mobil Otomobil Donanım Savunma Bilim Sosyal Medya İnternet Giyilebilir Teknoloji Rehber Ürünler Son dakika Yazarlar
  1. Ana sayfa
  2. Topluluk
  3. Programlama
  4. SDN Programlama Kafe
SDN Programlama Kafe

Office İşlemleri

OnurSorhan20.07.20125 cevap1.595 görüntüleme
2012'den beri808 mesaj
#1
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")
Cevaplar
2008'den beri174 mesaj
#2
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
}
2012'den beri250 mesaj
#3
if yerine switch kullanmanızı tavsiye ederim:


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 Konuyu açan
2012'den beri808 mesaj
#4
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 :)
2012'den beri250 mesaj
#5
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 Konuyu açan
2012'den beri808 mesaj
#6
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);

Cevabını yaz

Cevap yazmak için giriş yap ya da üye ol. Eski forum kullanıcı adın ve parolanla girebilirsin.