/// <summary>Read the content of a file directory.</summary> /// <param name="directoryName">The name of the directory.</param> /// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception> public List<FileDirectoryEntry> GetFileDirectory(string directoryName) { int error; IntPtr fileEntryList = IedConnection_getFileDirectory(connection, out error, directoryName); if (error != 0) throw new IedConnectionException("Reading file directory failed", error); List<FileDirectoryEntry> fileDirectory = new List<FileDirectoryEntry>(); IntPtr element = LinkedList_getNext(fileEntryList); while (element != IntPtr.Zero) { IntPtr elementData = LinkedList_getData(element); FileDirectoryEntry entry = new FileDirectoryEntry(elementData); fileDirectory.Add(entry); FileDirectoryEntry_destroy(elementData); element = LinkedList_getNext(element); } LinkedList_destroyStatic(fileEntryList); return fileDirectory; }
/// <exception cref="IedConnectionException">This exception is thrown if there is a connection or service error</exception> public List<string> GetServerDirectory(bool fileDirectory = false) { int error; IntPtr linkedList = IedConnection_getServerDirectory (connection, out error, fileDirectory); if (error != 0) throw new IedConnectionException ("GetDeviceDirectory failed", error); List<string> newList = new List<string> (); if (fileDirectory == false) { IntPtr element = LinkedList_getNext (linkedList); while (element != IntPtr.Zero) { string ld = Marshal.PtrToStringAnsi (LinkedList_getData (element)); newList.Add (ld); element = LinkedList_getNext (element); } LinkedList_destroy (linkedList); } else { IntPtr element = LinkedList_getNext(linkedList); while (element != IntPtr.Zero) { IntPtr elementData = LinkedList_getData(element); FileDirectoryEntry entry = new FileDirectoryEntry(elementData); newList.Add(entry.GetFileName()); FileDirectoryEntry_destroy(elementData); element = LinkedList_getNext(element); } LinkedList_destroyStatic(linkedList); } return newList; }