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

Is it possible to read and write in file at the same time?

Here's the scenario: ThreadA is going to read from some socket, and write data to "MyFile.txt" ThreadB is going to read "MyFile", and when it reaches the end, it will loops until new data are available in MyFile (because i don't want to re-open…
mohamida
  • 804
  • 2
  • 11
  • 25
8
votes
5 answers

Fast data recording/logging on a separate thread in C#

We're developing an application which reads data from a number of external hardware devices continuously. The data rate is between 0.5MB - 10MB / sec, depending on the external hardware configuration. The reading of the external devices is currently…
SomethingBetter
  • 1,294
  • 3
  • 16
  • 32
8
votes
2 answers

How to use Java 8 `Files.find` method?

I am trying to write an app to use Files.find method in it. Below program works perfectly : package ehsan; /* I have removed imports for code brevity */ public class Main { public static void main(String[] args) throws IOException { …
user6538026
8
votes
1 answer

Correct way to handle readFile and writeFile exceptions

I'm writing an application in Haskell and would like to display a meaningful error message to the user if readFile or writeFile fails. I'm currently catching IOErrors with Control.Exception.tryJust and converting them to human-readable…
Matthew
  • 193
  • 6
8
votes
3 answers

Working with files and utf8 in PHP

Lets say I have a file called foo.txt encoded in utf8: aoeu qjkx ñpyf And I want to get an array that contains all the lines in that file (one line per index) that have the letters aoeuñpyf, and only the lines with these letters. I wrote the…
Gerardo Marset
  • 803
  • 1
  • 10
  • 23
8
votes
2 answers

How to check if a file is already opened (in the same process)

And I'd like to specifically achieve that with the try catch construct. This related question suggests that I can do: try: open(fileName, 'wb+') except: print("File already opened!") raise However, it doesn't work me. I can open the…
Maxime Dupré
  • 5,319
  • 7
  • 38
  • 72
8
votes
3 answers

Open file in rich text box with C#

This question have been answered. I recommend sumit_programmers solution below. For now, I've removed my code, thinking it's more confusing than helpful. When I've developed it a bit further, perhaps I'll post my code here, with some comments. You…
matsolof
  • 2,665
  • 3
  • 18
  • 17
8
votes
1 answer

Vim gF should open file and jump to line

I tried out gF and it seems to not behave like mentioned in :help gF If cursor is positioned on an entry x.c and I type gf the file is opened. If cursor is positioned on an entry x.c:3 and I type gF I get E447: Can't find file "x.c:3" in path.…
vbd
  • 3,437
  • 4
  • 32
  • 45
8
votes
6 answers

Detect File Read in C#

I'm using FileSystemWatcher to check when a file is modified or deleted, but I'm wondering if there is any way to check when a file is read by another application. Example: I have the file C:\test.txt on my harddrive and am watching it using…
Petey B
  • 11,439
  • 25
  • 81
  • 101
8
votes
4 answers

How to merge efficiently gigantic files with C#

I have over 125 TSV files of ~100Mb each that I want to merge. The merge operation is allowed destroy the 125 files, but not the data. What matter is that a the end, I end up with a big file of the content of all the files one after the other (no…
Martin
  • 39,309
  • 62
  • 192
  • 278
8
votes
3 answers

Replace text in a file using Stream- Java 8

I'm trying to write an API to replace all the lines containing a certain substring with a different string in a text file. I’m using Java 8 stream to filter the lines which contains the given pattern. I’m having problem with the file write…
A.R.K.S
  • 1,692
  • 5
  • 18
  • 40
8
votes
2 answers

iOS photo extension finishContentEditingWithCompletionHandler: Unable to Save Changes

My photo extension app has access to both Camera and Photos. All is ok, but when pressing Done, it can not save image. Code of standard completion handler: - (void)finishContentEditingWithCompletionHandler:(void (^)(PHContentEditingOutput…
olha
  • 2,132
  • 1
  • 18
  • 39
8
votes
1 answer

Where to place test files for unit testing

I am writing some unit tests and I need to be able to access an external file. I assumed I could just place the file in my solution, mark it to be copied to the output directory, and then access it via a relative path. Unfortunately, it seems that…
KrisTrip
  • 4,943
  • 12
  • 55
  • 74
8
votes
6 answers

Reading all content from a text file - C

I am trying to read all content from a text file. Here is the code which I wrote. #include #include #define PAGE_SIZE 1024 static char *readcontent(const char *filename) { char *fcontent = NULL, c; int index = 0,…
Navaneeth K N
  • 15,295
  • 38
  • 126
  • 184
8
votes
2 answers

Programmatically determining the cause of IOException?

Is there any way to programmatically differentiate between what caused an IOException? For example Java will throw an IOException, if there was an error during writing. How can I tell, if it's something like access violation, if the Disk is out of…
UberJumper
  • 20,245
  • 19
  • 69
  • 87
1 2 3
99
100