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