WCM - Das österreichische Computer Magazin Forenübersicht
 

Zurück   WCM Forum > Rat & Tat > Programmierung

Programmierung Rat & Tat für Programmierer

Microsoft KARRIERECAMPUS

Antwort
 
Themen-Optionen Ansicht
Alt 25.08.2004, 10:08   #1
Daywalker23
Jr. Member
 
Registriert seit: 10.08.2004
Alter: 44
Beiträge: 33


Standard Dokument Properties mit dsofile.dll C#/ASP.NET

Hallo!
Ich habe folgendes Problem:
Ich möchte mir von Office Dokumenten die Custom Properties anzeigen lassen. Habe mir dazu die dsofile.dll besorgt und in darauf in meinem ASP.net Projekt verwiesen. Es funktioniert alles bis auf dass dass ich nicht den Wert eines Custom Properties abfragen kann. Ich kann den Namen und den Typ des Props abfragen.

Hier ist mein Code:

private void Page_Load(object sender, System.EventArgs e)
{
try
{
DSOleFile.PropertyReader objPropReader = new DSOleFile.PropertyReaderClass();
ArrayList arrListDocuments = new ArrayList();

DirectoryInfo di = new DirectoryInfo("c:/temp");
FileInfo[] rgFiles = di.GetFiles("*.doc");
foreach(FileInfo objFileInfo in rgFiles)
{
System.IO.FileAttributes objAttrFile = System.IO.File.GetAttributes(objFileInfo.FullName) ;

if ((objAttrFile & (System.IO.FileAttributes.Hidden | System.IO.FileAttributes.System)) != 0)
{
// Response.Write(objFileInfo.Name + ": Hidden Datei
");
}
else
{
arrListDocuments.Add(objFileInfo.FullName);
}
}

DSOleFile.DocumentProperties objDocumentProps;
objDocumentProps = objPropReader.GetDocumentProperties(arrListDocumen ts[0].ToString());

DSOleFile.CustomProperties objCustProps;

object ind = "Erste Eigenschaft";

Response.Write(objCustProps[ind].Name);
Response.Write(objCustProps[ind].Value.ToString());
}
catch(Exception ex)
{
Response.Write(ex.ToString());
}
}

Der Fehler tritt auf bei: Response.Write(objCustProps[ind].Value.ToString());
Ich bekomme die Meldung: Die Eigenschaft oder der Indexer "Value" wird von der Sprache nicht unterstützt wird. Versuchen Sie direkt die Accessor-Methoden "DSOleFile.CustomProperty.get_Value()" oder "DSOleFile.CustomProperty.set_Value(ref object)" aufzurufen.

Wie kann ich auf die Customprops eines Dokumentes mit ASP.net/C#
zugreifen? Hat da vielleicht schon einer Erfahrung damit?

Danke für eure Hilfe

Gerald
Daywalker23 ist offline   Mit Zitat antworten
Alt 25.08.2004, 13:47   #2
Abrix
Newbie
 
Registriert seit: 04.01.2002
Beiträge: 1


Standard

Hi,

probier's mal statt:


Response.Write(objCustProps[ind].Value.ToString());

so:

Response.Write(objDocumentProps.CustomProperties[ind].get_Value().ToString());


'objCustProps' brauch ma nicht.


mfg Robert
Abrix ist offline   Mit Zitat antworten
Alt 26.08.2004, 11:02   #3
Daywalker23
Jr. Member
 
Registriert seit: 10.08.2004
Alter: 44
Beiträge: 33


Standard

Hat funktioniert, danke.
Daywalker23 ist offline   Mit Zitat antworten
Alt 26.08.2004, 12:11   #4
Daywalker23
Jr. Member
 
Registriert seit: 10.08.2004
Alter: 44
Beiträge: 33


Standard

Hallo!
Habe ein weiteres Problem:
Es ist kein Problem die Properties von Dateien welche sich auf meinem Rechner befinden anzuzeigen, will ich jedoch die Props von Dateien,welche sich auf einem Network Share befinden anzeigen, bekomme ich eine Fehlermeldung. Ich bekomme zwar eine Liste mit allen Dateien im Network Share,jedoch kann ich die Properties nicht auslesen.

Hier ist der Code dazu:
Code:
private void Page_Load(object sender, System.EventArgs e)
		{		
			try
			{
				string strDirectory = @"\\test-server\temp";
				DSOleFile.PropertyReader objPropReader = new DSOleFile.PropertyReaderClass();
				ArrayList arrListDocuments = new ArrayList();

				DirectoryInfo di = new DirectoryInfo(strDirectory);
								
				FileInfo[] rgFiles = di.GetFiles();
				foreach(FileInfo objFileInfo in rgFiles)
				{
					System.IO.FileAttributes objAttrFile = System.IO.File.GetAttributes(objFileInfo.FullName);

					if ((objAttrFile & (System.IO.FileAttributes.Hidden | System.IO.FileAttributes.System)) != 0)
					{
//						Response.Write(objFileInfo.Name + ": Hidden Datei
");
					}
					else
					{
						arrListDocuments.Add(objFileInfo.FullName);
					}			
				}
				object[] objIndex = new object[2];
				objIndex[0] = "Erste Eigenschaft";
				objIndex[1] = "Zweite Eigenschaft";

				string strFileName = "";
				string strValue = "";

				TableRow row = new TableRow();
				TableCell cellName = new TableCell();
				cellName.Text = "Document Name";
				row.Cells.Add(cellName);

				for(int y = 0; y < objIndex.Length; y++)
				{
					TableCell cellPropName = new TableCell();
					cellPropName.Text = objIndex[y].ToString();
					row.Cells.Add(cellPropName);
				}
				row.BackColor = System.Drawing.Color.LightGray;
				myTable.Rows.Add(row);

				DSOleFile.DocumentProperties objDocumentProps;

				for(int i = 0; i < arrListDocuments.Count; i++)
				{
					strFileName = arrListDocuments[i].ToString();
					objDocumentProps = objPropReader.GetDocumentProperties(strFileName);
					TableRow row1 = new TableRow();
					TableCell cell = new TableCell();
					cell.Text = arrListDocuments[i].ToString();
					row1.Cells.Add(cell);

					for(int y = 0; y < objIndex.Length; y++)
					{
						
						
						strValue = "Nicht vorhanden";
						DSOleFile.CustomProperties custProps = objDocumentProps.CustomProperties;

						strValue = objDocumentProps.CustomProperties[objIndex[y]].get_Value().ToString() + " ";
						TableCell cell2 = new TableCell();
						cell2.Text = strValue;
						row1.Cells.Add(cell2);	
						
//						Response.Write(objDocumentProps.CustomProperties[objIndex[y]].get_Value().ToString() + " ");
					}
					myTable.Rows.Add(row1);
					
				}
//				Response.Write("
");				
			}
			catch(Exception ex)
			{
				Response.Write(ex.ToString());
			}
		}
Beim aufruf von objPropReader.GetDocumentProperties(strFileName) bekomme ich folgende Fehlermeldung:
System.Runtime.InteropServices.COMException: Ausnahme von HRESULT: 0x80030002 (STG_E_FILENOTFOUND).

Der Pfad zur Datei stimmt aber. Woran kann das liegen?

Danke für eure Hilfe.

Gerald
Daywalker23 ist offline   Mit Zitat antworten
Antwort


Aktive Benutzer in diesem Thema: 1 (Registrierte Benutzer: 0, Gäste: 1)
 

Forumregeln
Es ist Ihnen nicht erlaubt, neue Themen zu verfassen.
Es ist Ihnen nicht erlaubt, auf Beiträge zu antworten.
Es ist Ihnen nicht erlaubt, Anhänge hochzuladen.
Es ist Ihnen nicht erlaubt, Ihre Beiträge zu bearbeiten.

BB-Code ist an.
Smileys sind an.
[IMG] Code ist an.
HTML-Code ist aus.

Gehe zu


Alle Zeitangaben in WEZ +2. Es ist jetzt 02:24 Uhr.


Powered by vBulletin® Copyright ©2000 - 2025, Jelsoft Enterprises Ltd.
Forum SEO by Zoints
© 2009 FSL Verlag