getStandardPath()

The function getStandardPath() returns the directory path (location) where files of type (see parameter "type" below) should be written to, or an empty string if the location cannot be determined.

Synopsis

string getStandardPath(stringtype);

Parameters

Parameter Description
type
  • "Desktop"
  • "Documents"
  • "GenericData"
  • "Music"
  • "Movies"
  • "Pictures"
  • "Temp"
  • "Home"
  • "Cache"
  • "Download"
  • "AppData"
  • "AppLocalData"

Further information about the default paths can be found within the Qt documentation. Please note that not all Qt paths are available within WinCC OA.

Return value

The function returns the directory path (location) where files of type "type" (see parameter "type" above) should be written to, or an empty string if the location cannot be determined. The returned path ends with the operating system specific delimiter ("\" or "/").

Error

Missing or wrong arguments.

Description

The function getStandardPath() returns the directory path (location) where files of type "type" (see parameter "type" above) should be written to. If the correpsonding folder is not available the function tries to create the folder. If the directory can still not be determined than the function returns an empty string.

This function can be used to download files. For example to open and show a file. The function is, for example, needed on mobile operating systems where the UI runs in a restricted environment and where other applications cannot access the files in the project's cache directory.

Some locations (directory paths) are application-specific. Thus, you cannot access them via other apps.

Example

The following example opens a pdf file, shows an image and plays a music file. You can use this function also for the web client or in a UI that was started with the option -mobile or with the option -server.

main()
{
  mapping m;
  netGet(getActiveHttpServerUrl() + "/data/linux.pdf", m,makeMapping("target",
    getStandardPath("GenericData")));
  openUrl(m["target"]);
//The openUrl function opens a
    URL (web address). The code above opens a pdf file
}
/* The function getActiveHttpServerUrl returns the
URL of the active HTTP server. The server must be a known HTTP server otherwise
an empty string is returned */
//The following code shows an image:
main()
{
  mapping m;
  netGet(getActiveHttpServerUrl() + "/data/Bild1.jpg", m,makeMapping("target",
    getStandardPath("Pictures")));
  openUrl(m["target"]);
}
//The following code plays a music file
main()
{
  mapping m;
  netGet(getActiveHttpServerUrl() + "/data/music.ogg", m,makeMapping("target",
    getStandardPath("Music")));
  openUrl(m["target"]);
}

Assignment

Miscellaneous functions

Availability

UI