Maxon Developers Maxon Developers
    • Documentation
      • Cinema 4D Python API
      • Cinema 4D C++ API
      • Cineware API
      • ZBrush GoZ API
      • Code Examples on Github
    • Forum
    • Downloads
    • Support
      • Support Procedures
      • Registered Developer Program
      • Plugin IDs
      • Contact Us
    • Categories
      • Overview
      • News & Information
      • Cinema 4D SDK Support
      • Cineware SDK Support
      • ZBrush 4D SDK Support
      • Bugs
      • General Talk
    • Unread
    • Recent
    • Tags
    • Users
    • Login
    1. Maxon Developers Forum
    2. JPeters
    3. Posts
    J
    • Profile
    • Following 0
    • Followers 0
    • Topics 1
    • Posts 1
    • Best 0
    • Controversial 0
    • Groups 0

    Posts made by JPeters

    • Python writing to desktop

      Hi there,

      I've got a question, in my plugin I'm trying to create a directory on the Windows users' desktop to write files to with the following code:

      username = os.getlogin()    #Get the windows user name
      
      SavePathPackage = 'C:\\Users\\{username}\\Desktop\\TurnTableTool\\'
      
      # -----Checking if directories exist, if not create them-----#
      if (os.path.exists(SavePathPackage)):
          print("Path found on desktop")
      else:
          os.makedirs("C:\\Users\\{username}\\Desktop\\TurnTableTool")
          print("Created path on desktop")
      

      However, this throws en error:
      “winerror 5 access is denied”

      The usual fix is to run the code as admin but since this is a plugin within Cinema, that is not possible.

      Any pointers perhaps?

      posted in General Talk python r25
      J
      JPeters