我想通过 UI 路径工作室在 C 或 D 驱动器中创建一个主文件夹。创建主文件夹后,我想在主文件夹中创建三个文件夹。
如何在 UIpath 中解决此问题?
使用Create Directory
UiPath 中的活动。
只需在Activites
窗口中搜索即可。
您必须正确提及路径,如下所示:-
"C:\Users\Documents\UiPath\Your_Folder_Name"
Create directory
活动将是执行此操作的关键,在此之前,请确保您(您的 UiPath)确实有权在您的 C-Drive 和/或 D-Drive 中创建文件夹(如果您的 C-Drive 对您登录的在用户中,机器人不能做任何事情)。
我编写了以下对我有用的简单示例,只需将它们保存到扩展名为 .xaml 的记事本中,然后使用 UiPath 打开。通过运行它,您的 C-Drive 和 D-Drive 都应该创建一个名为 MasterFolderC 或 MasterFolderD 的文件夹,下面有 3 个子文件夹。
希望能帮助到你。
<Activity mc:Ignorable="sap sap2010 sads" x:Class="Main" mva:VisualBasic.Settings="{x:Null}" sap2010:WorkflowViewState.IdRef="Main_1"
xmlns="http://schemas.microsoft.com/netfx/2009/xaml/activities"
xmlns:av="http://schemas.microsoft.com/winfx/2006/xaml/presentation"
xmlns:mc="http://schemas.openxmlformats.org/markup-compatibility/2006"
xmlns:mva="clr-namespace:Microsoft.VisualBasic.Activities;assembly=System.Activities"
xmlns:sads="http://schemas.microsoft.com/netfx/2010/xaml/activities/debugger"
xmlns:sap="http://schemas.microsoft.com/netfx/2009/xaml/activities/presentation"
xmlns:sap2010="http://schemas.microsoft.com/netfx/2010/xaml/activities/presentation"
xmlns:scg="clr-namespace:System.Collections.Generic;assembly=mscorlib"
xmlns:sco="clr-namespace:System.Collections.ObjectModel;assembly=mscorlib"
xmlns:ui="http://schemas.uipath.com/workflow/activities"
xmlns:x="http://schemas.microsoft.com/winfx/2006/xaml">
<TextExpression.NamespacesForImplementation>
<sco:Collection x:TypeArguments="x:String">
<x:String>System.Activities</x:String>
<x:String>System.Activities.Statements</x:String>
<x:String>System.Activities.Expressions</x:String>
<x:String>System.Activities.Validation</x:String>
<x:String>System.Activities.XamlIntegration</x:String>
<x:String>Microsoft.VisualBasic</x:String>
<x:String>Microsoft.VisualBasic.Activities</x:String>
<x:String>System</x:String>
<x:String>System.Collections</x:String>
<x:String>System.Collections.Generic</x:String>
<x:String>System.Data</x:String>
<x:String>System.Diagnostics</x:String>
<x:String>System.Drawing</x:String>
<x:String>System.IO</x:String>
<x:String>System.Linq</x:String>
<x:String>System.Net.Mail</x:String>
<x:String>System.Xml</x:String>
<x:String>System.Xml.Linq</x:String>
<x:String>UiPath.Core</x:String>
<x:String>UiPath.Core.Activities</x:String>
<x:String>System.Windows.Markup</x:String>
</sco:Collection>
</TextExpression.NamespacesForImplementation>
<TextExpression.ReferencesForImplementation>
<sco:Collection x:TypeArguments="AssemblyReference">
<AssemblyReference>System.Activities</AssemblyReference>
<AssemblyReference>Microsoft.VisualBasic</AssemblyReference>
<AssemblyReference>mscorlib</AssemblyReference>
<AssemblyReference>System.Data</AssemblyReference>
<AssemblyReference>System</AssemblyReference>
<AssemblyReference>System.Drawing</AssemblyReference>
<AssemblyReference>System.Core</AssemblyReference>
<AssemblyReference>System.Xml</AssemblyReference>
<AssemblyReference>System.Xml.Linq</AssemblyReference>
<AssemblyReference>UiPath.Core</AssemblyReference>
<AssemblyReference>UiPath.Core.Activities</AssemblyReference>
<AssemblyReference>PresentationFramework</AssemblyReference>
<AssemblyReference>WindowsBase</AssemblyReference>
<AssemblyReference>PresentationCore</AssemblyReference>
<AssemblyReference>System.Xaml</AssemblyReference>
<AssemblyReference>System.ComponentModel.Composition</AssemblyReference>
<AssemblyReference>System.ServiceModel</AssemblyReference>
</sco:Collection>
</TextExpression.ReferencesForImplementation>
<Flowchart sap2010:WorkflowViewState.IdRef="Flowchart_1">
<Flowchart.Variables>
<Variable x:TypeArguments="x:String" Default="C:\MasterFolderC\" Name="MasterPathC" />
<Variable x:TypeArguments="x:String" Default="D:\MasterFolderD\" Name="MasterPathD" />
</Flowchart.Variables>
<Flowchart.StartNode>
<FlowStep x:Name="__ReferenceID0" sap2010:WorkflowViewState.IdRef="FlowStep_4">
<Sequence DisplayName="Creating Folders" sap2010:WorkflowViewState.IdRef="Sequence_3">
<Sequence DisplayName="C-Drive" sap2010:WorkflowViewState.IdRef="Sequence_4">
<Sequence.Variables>
<Variable x:TypeArguments="x:Boolean" Name="pathExist" />
</Sequence.Variables>
<ui:PathExists DisplayName="Path exists" Exists="[pathExist]" sap2010:WorkflowViewState.IdRef="PathExists_2" Path="[MasterPathC]" PathType="Folder" />
<If Condition="[pathExist]" sap2010:WorkflowViewState.IdRef="If_7">
<If.Then>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_5" Path="[MasterPathC]" />
</If.Then>
</If>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_6" Path="[MasterPathC + "SubFolder1"]" />
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_7" Path="[MasterPathC + "SubFolder2"]" />
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_8" Path="[MasterPathC + "SubFolder3"]" />
</Sequence>
<Sequence DisplayName="D-Drive" sap2010:WorkflowViewState.IdRef="Sequence_5">
<Sequence.Variables>
<Variable x:TypeArguments="x:Boolean" Name="pathExist" />
</Sequence.Variables>
<ui:PathExists DisplayName="Path exists" Exists="[pathExist]" sap2010:WorkflowViewState.IdRef="PathExists_3" Path="[MasterPathD]" PathType="Folder" />
<If Condition="[pathExist]" sap2010:WorkflowViewState.IdRef="If_8">
<If.Then>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_9" Path="[MasterPathD]" />
</If.Then>
</If>
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_10" Path="[MasterPathD + "SubFolder1"]" />
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_11" Path="[MasterPathD + "SubFolder2"]" />
<ui:CreateDirectory ContinueOnError="{x:Null}" DisplayName="Create directory" sap2010:WorkflowViewState.IdRef="CreateDirectory_12" Path="[MasterPathD + "SubFolder3"]" />
</Sequence>
</Sequence>
</FlowStep>
</Flowchart.StartNode>
<x:Reference>__ReferenceID0</x:Reference>
<sads:DebugSymbol.Symbol>dzFDOlxVc2Vyc1xtbWlhb1xEZXNrdG9wXFRlc3RpbmdXb3JrcGxhY2VcTWFpbi54YW1sIDsDZA8CAQE9ND1HAgEDPjQ+RwIBAkIJXxQCAQRDC1AWAgEaUQteFgIBBUcNR6MBAgEqSA1MEgIBJE0NTb8BAgEhTg1OvwECAR5PDU+/AQIBG1UNVaMBAgEVVg1aEgIBD1sNW8ABAgEMXA1cwAECAQldDV3AAQIBBkc9R0oCAS1Hf0eOAQIBK0gbSCgCASVKEUqqAQIBJ02UAU28AQIBIk6UAU68AQIBH0+UAU+8AQIBHFU9VUoCARhVf1WOAQIBFlYbVigCARBYEViqAQIBEluVAVu9AQIBDVyVAVy9AQIBCl2VAV29AQIBB0qYAUqnAQIBKFiYAVinAQIBEw==</sads:DebugSymbol.Symbol>
</Flowchart>
<sap2010:WorkflowViewState.ViewStateManager>
<sap2010:ViewStateManager>
<sap2010:ViewStateData Id="PathExists_2" sap:VirtualizedContainerService.HintSize="464,89" />
<sap2010:ViewStateData Id="CreateDirectory_5" sap:VirtualizedContainerService.HintSize="200,22" />
<sap2010:ViewStateData Id="If_7" sap:VirtualizedContainerService.HintSize="464,208" />
<sap2010:ViewStateData Id="CreateDirectory_6" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="CreateDirectory_7" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="CreateDirectory_8" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="Sequence_4" sap:VirtualizedContainerService.HintSize="200,51">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="PathExists_3" sap:VirtualizedContainerService.HintSize="464,89" />
<sap2010:ViewStateData Id="CreateDirectory_9" sap:VirtualizedContainerService.HintSize="200,22" />
<sap2010:ViewStateData Id="If_8" sap:VirtualizedContainerService.HintSize="464,208" />
<sap2010:ViewStateData Id="CreateDirectory_10" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="CreateDirectory_11" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="CreateDirectory_12" sap:VirtualizedContainerService.HintSize="464,22" />
<sap2010:ViewStateData Id="Sequence_5" sap:VirtualizedContainerService.HintSize="200,51">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<x:Boolean x:Key="IsPinned">False</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="Sequence_3" sap:VirtualizedContainerService.HintSize="222,266">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">True</x:Boolean>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="FlowStep_4">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<av:Point x:Key="ShapeLocation">200,127.5</av:Point>
<av:Size x:Key="ShapeSize">200,51</av:Size>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="Flowchart_1" sap:VirtualizedContainerService.HintSize="614,636">
<sap:WorkflowViewStateService.ViewState>
<scg:Dictionary x:TypeArguments="x:String, x:Object">
<x:Boolean x:Key="IsExpanded">False</x:Boolean>
<av:Point x:Key="ShapeLocation">270,2.5</av:Point>
<av:Size x:Key="ShapeSize">60,75</av:Size>
<av:PointCollection x:Key="ConnectorLocation">300,77.5 300,127.5</av:PointCollection>
</scg:Dictionary>
</sap:WorkflowViewStateService.ViewState>
</sap2010:ViewStateData>
<sap2010:ViewStateData Id="Main_1" sap:VirtualizedContainerService.HintSize="654,716" />
</sap2010:ViewStateManager>
</sap2010:WorkflowViewState.ViewStateManager>
</Activity>