Forums

How to write to a .txt file in my Dropbox

I am trying to write (or append) to a .txt file in my Dropbox shared folder but I keep getting an error that the folder or directory doesn't exist. What exactly is the path structure to the files and folders on my dropbox? I've tried the usual path to my dropbox folder on my desktop but no luck. Thanks

Hi Zanderearth,

The full path to the shared folder you have created inside Dropbox would be:

"/home/zanderearth/Dropbox/Shared/"

So a bit of Python like this should work:

with open("/home/zanderearth/Dropbox/Shared/test_file.txt", "a") as file:
    file.write("This worked!")

Should succeed.