> For the complete documentation index, see [llms.txt](https://chaoses-ib.gitbook.io/directory-opus/llms.txt). Markdown versions of documentation pages are available by appending `.md` to page URLs; this page is available as [Markdown](https://chaoses-ib.gitbook.io/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh-1/onbeforefolderchange.zh.md).

# OnBeforeFolderChange

**OnBeforeFolderChange** 事件可以通过 [脚本加载项](/directory-opus/guan-fang-shou-ce/readme.zh-8/readme.zh-1.md) 实现，以便在新的文件夹被读取到标签中时收到通知。如果需要在文件夹读取 *之后* 收到通知，可以使用 **OnAfterFolderChange** 事件。

| **方法名称:**  | OnBeforeFolderChange                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                      |
| ---------- | ----------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------- |
| **参数类型:**  | [**BeforeFolderChangeData**](/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh/beforefolderchangedata.zh.md)                                                                                                                                                                                                                                                                                                                                                                                                           |
| **返回值类型:** | *bool* 或 *string*                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                         |
| **描述:**    | <p><strong>BeforeFolderChangeData.tab</strong> 属性标识标签，<strong>path</strong> 属性标识即将读取的文件夹。<strong>initial</strong> 属性指示这是否是读取到此标签的第一个文件夹 - 如果为 <strong>True</strong>，则意味着该标签以前是空的或新打开的。</p><p>你可以从这个事件中返回两种不同的类型：</p><ul><li><em>bool</em>: 如果返回 <strong>True</strong>，文件夹读取将被阻止，并且标签将保持不变。如果你返回 <strong>False</strong>，读取将被允许继续（这是默认值）。</li><li><em>string</em>: 你可以返回一个 <em>string</em>（或 <a href="/directory-opus/guan-fang-shou-ce/readme.zh-10/readme.zh-3/readme.zh/path.zh.md"><strong>Path</strong></a> 对象）来更改要读取的文件夹路径。</li></ul> |
