activities
latest
false
Importante :
A tradução automática foi aplicada parcialmente neste conteúdo. A localização de um conteúdo recém-publicado pode levar de 1 a 2 semanas para ficar disponível.
UiPath logo, featuring letters U and I in white

Atividades do fluxo de trabalho

Última atualização 6 de mar de 2026

Get Environment Folder

UiPath.Core.Activities.GetEnvironmentFolder

Use this activity to retrieve the path to system special folders (such as Desktop, Documents, AppData, etc.) using .NET's Environment.SpecialFolder enumeration. Understanding the platform-specific behavior is essential for building reliable cross-platform automation workflows.

Observação:

The SpecialFolder enumeration is consistent across platforms, but the actual folder mappings and availability differ significantly between Windows and cross-platform environments. Many Windows-specific folders return an empty string on Linux/macOS.

Propriedades

Comum
  • DisplayName - O nome de exibição da atividade.
Entrada
  • SpecialFolder - The SpecialFolder whose path is to be retrieved. Select from the available Environment.SpecialFolder enumeration values.
Saída
  • FolderPath - The full folder path of the selected SpecialFolder. Returns an empty string if the folder is not available on the current platform.
Diversos
  • Privado - Se selecionado, os valores de variáveis e argumentos não são mais registrados no nível Verbose.

Platform-specific behavior

Windows environment

When running on Windows:

  • All standard special folders resolve to their expected Windows paths (e.g., Desktop, ProgramFiles, System, ApplicationData).
  • Windows-only folders such as ProgramFiles, ProgramFilesX86, Windows, AdminTools, and CommonProgramFiles return valid paths.
  • Folders typically resolve to locations under C:\Users\<username> or system directories like C:\Windows.

Cross-platform environment

When running on Linux or macOS:

  • Only a subset of special folders resolve to valid paths; many Windows-specific folders return an empty string.
  • Folder paths follow XDG Base Directory specifications on Linux (using environment variables like $XDG_CONFIG_HOME, $XDG_DATA_HOME) and macOS conventions.
  • The activity never creates directories; it only resolves known locations based on the operating system.
  • If a folder cannot be resolved on the current platform, the activity returns an empty string (not null) and does not throw an exception.

Common folder mappings

Cross-platform folders

These folders typically resolve on both Windows and cross-platform environments:

  • UserProfile - Windows: C:\Users\<user>, Linux/macOS: $HOME
  • Desktop - Windows: C:\Users\<user>\Desktop, Linux/macOS: ~/Desktop (if present)
  • MyDocuments - Windows: C:\Users\<user>\Documents, Linux/macOS: ~/Documents (if present)
  • ApplicationData - Windows: %APPDATA% (Roaming), Linux/macOS: ~/.config (XDG)
  • LocalApplicationData - Windows: %LOCALAPPDATA%, Linux/macOS: ~/.local/share (XDG)

Windows-only folders

These folders return valid paths on Windows but typically return an empty string on Linux/macOS:

  • ProgramFiles, ProgramFilesX86 - Windows program installation directories
  • System, SystemX86, Windows - Windows system directories
  • CommonApplicationData - Windows: %PROGRAMDATA%, Linux/macOS: empty string
  • CommonProgramFiles, CommonProgramFilesX86 - Shared program files
  • AdminTools, Templates, Favorites, Recent, SendTo, StartMenu, Startup - Windows shell folders

Platform-specific considerations

  • Fonts - Windows: %WINDIR%\Fonts, macOS: /System/Library/Fonts (system) or /Library/Fonts (user), Linux: varies by distribution, often returns empty string
  • Desktop, MyDocuments - May return empty string if the directory doesn't exist in the user profile, even on platforms where they are expected

Melhores práticas

  • Always validate the result: Check for string.IsNullOrEmpty(folderPath) before using the returned path, as many folders may not exist on certain platforms.
  • For cross-platform workflows: Prefer using UserProfile, ApplicationData, or LocalApplicationData for storing application data, as these have consistent mappings across platforms.
  • Avoid Windows-only folders: Don't rely on folders like ProgramFiles, System, or Windows in cross-platform workflows, as they will return empty strings on Linux/macOS.
  • Handle missing directories: The activity does not create directories. If you need to write to a special folder, verify it exists and create it if necessary.
  • Test on target platforms: Folder availability can vary based on user profile configuration, especially for presence-sensitive folders like Desktop and Documents.
  • Containerized environments: Be aware that containerized or restricted environments may return empty strings for more folders due to missing or inaccessible paths.

RetornarValor

  • Returns the full folder path as a string if the special folder is available on the current platform.
  • Returns an empty string (string.Empty) if the folder cannot be resolved on the current platform.
  • Never returns null and does not throw exceptions for unsupported folders.

Exemplos de cenários

Scenario 1: Retrieving UserProfile

  • Windows: Returns C:\Users\<username>
  • Linux/macOS: Returns /home/<username> or /Users/<username>

Scenario 2: Retrieving ProgramFiles

  • Windows: Returns C:\Program Files
  • Linux/macOS: Returns empty string

Scenario 3: Retrieving ApplicationData

  • Windows: Returns C:\Users\<username>\AppData\Roaming
  • Linux/macOS: Returns ~/.config (XDG specification)

Scenario 4: Retrieving Desktop when folder doesn't exist

  • All Platforms: Returns empty string if the Desktop folder is not present in the user profile

Esta página foi útil?

Conectar

Precisa de ajuda? Suporte

Quer aprender? Academia UiPath

Tem perguntas? Fórum do UiPath

Fique por dentro das novidades