Indicates the file's changed state.
Type | Description | |||
ChangeEnum | A ChangeEnum expression that indicates the file's state. |
The State property specifies if the file/folder was added, removed or changed during the Change event. The Change event is fired when the system notifies the control that there was a change in the browsed folder. Use the BrowseFolderPath property to indicates the browsed folder. The State property is Unchanged, if the State property is called outside of Change event. Use the Folder property to specify whether the object holds information about a folder of a file. Use the Item property to access a file giving its index in the Files collection. Use the Count property to retrieve the number of File objects in the Files collection.
The following VB sample displays the files that have been changed in the browsed folder:
Private Sub ExFileView1_Change(ByVal Files As EXFILEVIEWLibCtl.IFiles) Dim f As EXFILEVIEWLibCtl.File For Each f In Files Debug.Print "'" & f.Name & "' " & IIf(f.Folder, "foder", "file") & " " & IIf(f.State = Added, "added", IIf(f.State = Changed, "changed", IIf(f.State = Deleted, "deleted", "unchanged"))) Next End Sub
Open a new Windows Explorer instance that browses the same folder as your control. Add new folders, remove folders, or change regular files. Your VB output should look like the following:
The 'New Folder (2)' foder - Added The 'New Folder (2)' foder - Deleted The 'New Folder' foder was deleted The 'New Text Document.txt' file was added The 'New Text Document.txt' file was changed
The following C++ sample displays the files that have been changed in the browsed folder:
#include "Files.h" #include "File.h" void OnChangeExfileview1(LPDISPATCH Files) { CFiles files( Files ); files.m_bAutoRelease = FALSE; for ( long i = 0; i < files.GetCount(); i++ ) { CFile1 file = files.GetItem( COleVariant( long( i ) ) ); CString strState; switch ( file.GetState() ) { case 0: { strState = "unchanged"; break; } case 1: { strState = "changed"; break; } case 2: { strState = "added"; break; } case 3: { strState = "deleted"; break; } } CString strOutput; strOutput.Format( "'%s' %s %s\n", file.GetName(), (file.GetFolder() ? "folder" : "file" ), strState ); OutputDebugString( strOutput ); } }
The following VB.NET sample displays the files that have been changed in the browsed folder:
Private Sub AxExFileView1_Change(ByVal sender As Object, ByVal e As AxEXFILEVIEWLib._IExFileViewEvents_ChangeEvent) Handles AxExFileView1.Change Dim f As EXFILEVIEWLib.File For Each f In e.files Debug.WriteLine("'" & f.Name & "' " & IIf(f.Folder, "foder", "file") & " " & IIf(f.State = EXFILEVIEWLib.ChangeEnum.Added, "added", IIf(f.State = EXFILEVIEWLib.ChangeEnum.Changed, "changed", IIf(f.State = EXFILEVIEWLib.ChangeEnum.Deleted, "deleted", "unchanged")))) Next End Sub
The following C# sample displays the files that have been changed in the browsed folder:
private void axExFileView1_Change(object sender, AxEXFILEVIEWLib._IExFileViewEvents_ChangeEvent e) { for (int i = 0; i < e.files.Count; i++) { EXFILEVIEWLib.File file = e.files[i]; string strOutput = "'" + file.Name + "' "; strOutput += (file.Folder ? "folder" : "file") + " "; strOutput += (file.State == EXFILEVIEWLib.ChangeEnum.Added ? "added" : (file.State == EXFILEVIEWLib.ChangeEnum.Deleted ? "deleted" : (file.State == EXFILEVIEWLib.ChangeEnum.Changed ? "changed" : "unchanged"))); System.Diagnostics.Debug.WriteLine(strOutput); } }
The following VFP sample displays the files that have been changed in the browsed folder:
*** ActiveX Control Event *** LPARAMETERS files with files local i for i = 0 to .Count - 1 with .Item(i) wait window nowait .Name + " " + str(.State) endwith next endwith