Questions tagged [file-io]

File I/O is input/output that involves the file system. This could include performing operations on directories and files, such as creation and deletion, reading files, and writing output to files.

For an introduction on File I/O in C, see C Programming / File I/O on Wikibooks.

21104 questions
8
votes
1 answer

Specifying initial directory for NSOpenPanel RunModal?

Seems like I must be overlooking something in documentation. How do I specify a directory I want to start in when I use runModal with NSOpenPanel. Some methods are deprecated in 10.6.
terratactile
  • 85
  • 1
  • 6
8
votes
4 answers

is there COMMIT analog in python for writing into a file?

I have a file open for writing, and a process running for days -- something is written into the file in relatively random moments. My understanding is -- until I do file.close() -- there is a chance nothing is really saved to disk. Is that…
user63503
  • 6,243
  • 14
  • 41
  • 44
8
votes
6 answers

Why is file I/O in large chunks SLOWER than in small chunks?

If you call ReadFile once with something like 32 MB as the size, it takes noticeably longer than if you read the equivalent number of bytes with a smaller chunk size, like 32 KB. Why? (No, my disk is not busy.) Edit 1: Forgot to mention -- I'm…
user541686
  • 205,094
  • 128
  • 528
  • 886
8
votes
2 answers

How do I find out whether a file is within a directory with Node.js?

Given two absolute or relative paths, A and B, I want to find out whether B is "inside of" the directory A—not just in the directory itself, but potentially in a subdirectory. I'd like to do this without a potentially huge number of fs.readdir…
Trevor Burnham
  • 76,828
  • 33
  • 160
  • 196
8
votes
6 answers

C++ FILE without writing to disk

I'm using a library that has quite a few functions that write to a FILE but none that seem to conveniently dump the same data to an object in memory. Is there any way to create a FILE object (or override it) that stores the data in memory instead…
jnpdx
  • 45,847
  • 6
  • 64
  • 94
8
votes
4 answers

How to unread a line in python

I am new to Python (2.6), and have a situation where I need to un-read a line I just read from a file. Here's basically what I am doing. for line in file: print line file.seek(-len(line),1) zz = file.readline() print…
user721975
  • 1,257
  • 3
  • 13
  • 14
8
votes
5 answers

Writing ALL program output to a txt file in C++

I need to write all my program output to a text file. I believe it's done this way, sOutFile << stdout; where sOutFile is the ofstream object that creates the file like this: sOutFile("CreateAFile.txt" ); // CreateAFile.txt is created. When I…
user40120
  • 648
  • 5
  • 28
  • 58
8
votes
1 answer

Read File At Compile Time (constexpr or other)

Does C++17 offer any way to load/read a file at compile time? More specifically, I want to load a file's content into a const char* or std::string_view, etc. For example: constexpr const char* read_file_content(const char* file_path) { …
Phil-ZXX
  • 2,359
  • 2
  • 28
  • 40
8
votes
2 answers

file input MVC 3 Client-side validation for required

Simple question... Is it possible to use client side MVC 3 validation on inputs of type file? To explain: MVC 3 uses its model validation with IClientValidatable and unobtrusive javascript to allow you to write validation on the server side and…
Jay
  • 2,715
  • 8
  • 33
  • 33
8
votes
3 answers

Check if File exists in directory ignoring the extension

I am using .NET 2.0 and Linq is out of question. I would like to check if file exists inside a directory without knowledge of the file extension. I just need this logic done. 1.Check File exists in Directory using String Filename provided using…
Deeptechtons
  • 10,945
  • 27
  • 96
  • 178
8
votes
6 answers

read/write to a large size file in java

i have a binary file with following format : [N bytes identifier & record length] [n1 bytes data] [N bytes identifier & record length] [n2 bytes data] [N bytes identifier & record length] [n3 bytes data] as you see i have records with different…
mhshams
  • 16,384
  • 17
  • 55
  • 65
8
votes
7 answers

How to delete all files from current directory including current directory?

How can I delete all files and subdirectories from current directory including current directory?
Ib33X
  • 6,764
  • 4
  • 28
  • 30
8
votes
3 answers

Java - write dll files from inside a jar to the hard drive?

I have a signed applet and I want to write out dll files which are contained in the jar from which I launch my applet. I am doing this because I then want to do a System.load on the dll's, as apparently you can't load DLL's from inside a jar in an…
KaiserJohaan
  • 9,028
  • 20
  • 112
  • 199
8
votes
6 answers

What is the ideal memory block size to use when copying?

I am currently using 100 megabytes per memory block to copy large files. Is there a "good" amount that people normally use? Edit Thanks for all the great responses. I'm still quite new to these concepts so I'll try to understand a lot of the ones…
Zac Blazic
  • 607
  • 2
  • 6
  • 17
8
votes
2 answers

How to manage the transaction(which includes File IO) when an IOException is thrown from the close file method

I've recently begun using Spring's Data Source Transaction Manager. I have a problem now. My transaction includes updates to a DB table and a write operation to a file. It works fine but I have some doubts about file I/O. As you see below, I have…
Kivanc
  • 246
  • 1
  • 7
  • 13