FILE PATHS AND
PROGRAMMING
SARAH BETH BENES
WHAT IS A FILE PATH?
• A program will first look in the current directory for
• data files
• module files
• Next it will look in a specified file path
• Your compiler has default paths for built in modules
• Advanced programming, you will want to specify your own
file paths
• For now, keep everything in the same directory
TWO WAYS TO SEE A FILE PATH
FILE EXPLORER - LIBRARIES FILE EXPLORER – DISK VIEW
TWO WAYS TO SEE A FILE PATH
FILE EXPLORER - LIBRARIES
• at the top it shows the file
path.
• Starting from “libraries”
• LibrariesDocuments
• STCPythonChapter Files
TWO WAYS TO SEE A FILE PATH
FILE EXPLORER - LIBRARIES FILE EXPLORER DISK VIEW
• at the top it shows the file
path.
• Starting from “c:”
• C:UsersPublicPublic
Documents
• STCPythonChapter Files
THE FILE PATH YOU NEED TO KNOW
•Both of these are the same file location
•You need to know the file path the computer
uses
•C:UsersPublicDocumentsSTCPythonChapt
er files
TO USE YOUR CURRENT LOCATION AS A
STARTING PLACE USE THE DOUBLE 
• STCPythonChapter
Files
• The problem with this
comes back to using a
space in a name
• Use good naming
conventions for your
disk, also
FLASH DRIVE
TO USE YOUR CURRENT LOCATION AS A
STARTING PLACE USE THE DOUBLE 
• STCPythonChapter
Files
• The problem with this
comes back to using a
space in a name
• Use good naming
conventions for your
disk, also
FLASH DRIVE
HOW TO SHARE IT
• If you are going to use your program on another computer
• Write the pathname relative to the drive it is on
• 
• Instead of a drive letter
• You will want to zip your entire folder, so that it can be
unzipped with the same relative locations
• See sample file

File paths and programming

  • 1.
  • 2.
    WHAT IS AFILE PATH? • A program will first look in the current directory for • data files • module files • Next it will look in a specified file path • Your compiler has default paths for built in modules • Advanced programming, you will want to specify your own file paths • For now, keep everything in the same directory
  • 3.
    TWO WAYS TOSEE A FILE PATH FILE EXPLORER - LIBRARIES FILE EXPLORER – DISK VIEW
  • 4.
    TWO WAYS TOSEE A FILE PATH FILE EXPLORER - LIBRARIES • at the top it shows the file path. • Starting from “libraries” • LibrariesDocuments • STCPythonChapter Files
  • 5.
    TWO WAYS TOSEE A FILE PATH FILE EXPLORER - LIBRARIES FILE EXPLORER DISK VIEW • at the top it shows the file path. • Starting from “c:” • C:UsersPublicPublic Documents • STCPythonChapter Files
  • 6.
    THE FILE PATHYOU NEED TO KNOW •Both of these are the same file location •You need to know the file path the computer uses •C:UsersPublicDocumentsSTCPythonChapt er files
  • 7.
    TO USE YOURCURRENT LOCATION AS A STARTING PLACE USE THE DOUBLE • STCPythonChapter Files • The problem with this comes back to using a space in a name • Use good naming conventions for your disk, also FLASH DRIVE
  • 8.
    TO USE YOURCURRENT LOCATION AS A STARTING PLACE USE THE DOUBLE • STCPythonChapter Files • The problem with this comes back to using a space in a name • Use good naming conventions for your disk, also FLASH DRIVE
  • 9.
    HOW TO SHAREIT • If you are going to use your program on another computer • Write the pathname relative to the drive it is on • • Instead of a drive letter • You will want to zip your entire folder, so that it can be unzipped with the same relative locations • See sample file