Questions tagged [file]

A block of arbitrary information, or resource for storing information, accessible by the string-based name or path. Files are available to computer programs and are usually based on some kind of persistent storage.

A computer file is a block of arbitrary information, or resource for storing information, which is available to a computer program and is usually based on some kind of durable storage. A file is durable in the sense that it remains available for programs to use after the current program has finished. Computer files can be considered as the modern counterpart of paper documents which traditionally are kept in offices' and libraries' files, and this is the source of the term.

In modern computer architectures, files are organized in a tree structure. On the top, you have a root like C:\ in systems. There are several subfolders (inner nodes) below the root, e.g. Program Files or Users. The computer files, which contain the data, are the leaves of that tree.

On based systems, many types of system information are also represented as files, in filesystems such as sysfs and devfs, even though they don't represent information on a durable storage medium.


References


Related

, , , , ,

81192 questions
7012
votes
40 answers

How do I check whether a file exists without exceptions?

How do I check whether a file exists or not, without using the try statement?
spence91
  • 77,143
  • 9
  • 27
  • 19
6246
votes
71 answers

How do I include a JavaScript file in another JavaScript file?

How do I include a JavaScript file inside another JavaScript file, similar to @import in CSS?
Alec Smart
  • 94,115
  • 39
  • 120
  • 184
3702
votes
21 answers

How to copy files

How do I copy a file in Python?
Matt
  • 84,419
  • 25
  • 57
  • 67
2069
votes
18 answers

Writing to files in Node.js

I've been trying to find a way to write to a file when using Node.js, but with no success. How can I do that?
Gjorgji
  • 22,458
  • 10
  • 31
  • 39
2027
votes
13 answers

How do I append to a file?

How do I append to a file instead of overwriting it?
user502039
2025
votes
28 answers

How to read a file line-by-line into a list?

How do I read every line of a file in Python and store each line as an element in a list? I want to read the file line by line and append each line to the end of the list.
Julie Raswick
  • 20,403
  • 3
  • 16
  • 3
2023
votes
15 answers

Undo working copy modifications of one file in Git

After the last commit, I modified a bunch of files in my working copy, but I want to undo the changes to one of those files, as in reset it to the same state as the most recent commit. However, I only want to undo the working copy changes of just…
hasen
  • 161,647
  • 65
  • 194
  • 231
1989
votes
19 answers

Why should text files end with a newline?

I assume everyone here is familiar with the adage that all text files should end with a newline. I've known of this "rule" for years but I've always wondered — why?
Will Robertson
  • 62,540
  • 32
  • 99
  • 117
1875
votes
43 answers

Download a single folder or directory from a GitHub repo

How can I download only a specific folder or directory from a remote Git repo hosted on GitHub? Say the example GitHub repo lives here: git@github.com:foobar/Test.git Its directory structure: Test/ ├── foo/ │ ├── a.py │ └── b.py └── bar/ …
g_inherit
  • 18,771
  • 3
  • 16
  • 5
1753
votes
35 answers

How do I create a Java string from the contents of a file?

I've been using the idiom below for some time now. And it seems to be the most wide-spread, at least on the sites I've visited. Is there a better/different way to read a file into a string in Java? private String readFile(String file) throws…
OscarRyz
  • 196,001
  • 113
  • 385
  • 569
1433
votes
11 answers

How do I move a file in Python?

How can I do the equivalent of mv in Python? mv "path/to/current/file.foo" "path/to/new/destination/for/file.foo"
David542
  • 104,438
  • 178
  • 489
  • 842
1281
votes
13 answers

How do I get file creation and modification date/times?

What's the best cross-platform way to get file creation and modification dates/times, that works on both Linux and Windows?
Mark Biek
  • 146,731
  • 54
  • 156
  • 201
1191
votes
12 answers

Remove a symlink to a directory

I have a symlink to an important directory. I want to get rid of that symlink, while keeping the directory behind it. I tried rm and get back rm: cannot remove 'foo'. I tried rmdir and got back rmdir: failed to remove 'foo': Directory not empty I…
Matthew Scouten
  • 15,303
  • 9
  • 33
  • 50
1113
votes
10 answers

How do I check file size in Python?

How do I get the size of a file in Python?
5YrsLaterDBA
  • 33,370
  • 43
  • 136
  • 210
1096
votes
22 answers

How to create a file in memory for user to download, but not through server?

Is there a way to create a text file on the client side and prompt the user to download it without any interaction with the server? I know I can't write directly to their machine (security and all), but can I create the file and prompt them to save…
Joseph Silber
  • 214,931
  • 59
  • 362
  • 292
1
2 3
99 100