重新路由文件和设置
为了重新路由文件和设置,应创建自定义 .xml 文件并在 ScanState 和 LoadState 命令行指定该文件名。该操作会让你的修改与默认 .xml 文件保持隔离,这样更易于跟踪修改。
本主题内容:
重新路由文件夹
重新路由特定文件类型
重新路由特定文件
重新路由文件夹
下述自定义 .xml 文件会将目录和文件从 C:\EngineeringDrafts 迁移到每位用户的“我的文档”文件夹。%CSIDL_PERSONAL% 是虚拟文件夹,代表“我的文档”桌面项,与 CSIDL_MYDOCUMENTS 等同。
<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="User">
<displayName>Engineering Drafts Documents to Personal Folder</displayName>
<role role="Data">
<rules>
<!-- Migrate all directories and files present in c:\EngineeringDrafts folder -->
<include>
<objectSet>
<pattern type="File">C:\EngineeringDrafts\* [*]</pattern>
</objectSet>
</include>
<!-- This migrates all files and directories from C:\EngineeringDrafts to every user’s personal folder.-->
<locationModify script="MigXmlHelper.RelativeMove('C:\EngineeringDrafts','%CSIDL_PERSONAL%')">
<objectSet>
<pattern type="File">C:\EngineeringDrafts\* [*]</pattern>
</objectSet>
</locationModify>
</rules>
</role>
</component>
</migration>
重新路由特定文件类型
下述自定义 .xml 文件将位于源计算机固定驱动器中的 .mp3 文件重新路由到目标计算机的 C:\Music 文件夹。
<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="System">
<displayName>All .mp3 files to My Documents</displayName>
<role role="Data">
<rules>
<include>
<objectSet>
<script>MigXmlHelper.GenerateDrivePatterns ("* [*.mp3]", "Fixed")</script>
</objectSet>
</include>
<!-- Migrates all the .mp3 files in the store to the C:\Music folder during LoadState -->
<locationModify script="MigXmlHelper.Move('C:\Music')">
<objectSet>
<script>MigXmlHelper.GenerateDrivePatterns ("* [*.mp3]", "Fixed")</script>
</objectSet>
</locationModify>
</rules>
</role>
</component>
</migration>
重新路由特定文件
下述自定义 .xml 文件会将 Sample.doc 从 C:\EngineeringDrafts 迁移到每位用户的“我的文档”文件夹。%CSIDL_PERSONAL% 是虚拟文件夹,代表“我的文档”桌面项,与 CSIDL_MYDOCUMENTS 等同。
<migration urlid="https://www.microsoft.com/migration/1.0/migxmlext/test">
<component type="Documents" context="User">
<displayName>Sample.doc into My Documents</displayName>
<role role="Data">
<rules>
<include>
<objectSet>
<pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
</objectSet>
</include>
<locationModify script="MigXmlHelper.RelativeMove('C:\EngineeringDrafts','%CSIDL_PERSONAL%')">
<objectSet>
<pattern type="File"> C:\EngineeringDrafts\ [Sample.doc]</pattern>
</objectSet>
</locationModify>
</rules>
</role>
</component>
</migration>