file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files
Questions tagged [file-handling]
2915 questions
5
votes
1 answer
Reading a growing file
If I encounter feof() and then stat shows that the file has grown, is there a way to read the added data without doing a fclose() and fopen()?

Fixee
- 1,581
- 2
- 15
- 25
5
votes
3 answers
Read File line by line to variable and loop
I have a phone.txt like:
09236235965
09236238566
09238434444
09202645965
09236284567
09236235965
..and so on..
How can I process this data line by line in C++ and add it to a variable.
string phonenum;
I know I have to open the file, but after…

user1553142
- 237
- 1
- 11
- 21
5
votes
3 answers
Howto create a directory under Linux which behaves like a pipe
We want to create a relative simple document storage but there are some requirements. My idea was, that a file is scanned and handled by a separate tool/daemon when it arrives at storage immediately.
The (pseudo) DMS should provide access via NFS…

rabudde
- 7,498
- 6
- 53
- 91
5
votes
2 answers
Android: How to open an unknown file type
I am developing a file explorer app in android.
How to handle files with unknown extensions? When I try to open such kind of file, its throwing ActivityNotFound exception. But I want the system to pop up list of apps so that we can manually choose…

rahul
- 6,447
- 3
- 31
- 42
5
votes
5 answers
Giving path of a file in C#
I want to open a xxx.txt file kept on desktop of my Computer but the program gives an
error Parser error unrecognized escape sequence '\D'. I am trying to give the path of the
file as "C:\Documents and Settings\user\Desktop\xxx.txt" .
Am i giving…

Sarao
- 379
- 1
- 7
- 18
4
votes
3 answers
How do I add a file browser inside my Java application?
I am new to Java progamming and am building a application that will add, display and remove files from a given folder location.
I have added files using JFileChooser and know how to delete the files. However I am stuck with the display portion.
I…

ranendra
- 2,492
- 2
- 19
- 29
4
votes
1 answer
Having problem understanding following C++ code. (seekp)
#include
#include
class Test
{
char name[10];
int data;
public:
void getData()
{
cin>>name;
cin>>data;
}
void display()
{
cout<

ATR
- 2,160
- 4
- 22
- 43
4
votes
4 answers
Modifying XML file in-place?
Suppose I have the following XML File:
sometext
sometext
sometext
Dometext
sometext
If I wanted to modify the content by changing D to s (As shown in the fourth…

Abhi
- 5,501
- 17
- 78
- 133
4
votes
2 answers
File pointer position in file handling
f=open("hello.txt","r+")
f.read(5)
f.write("op")
f.close()
the text file contains the following text:
python my world heellll mine
According to me after opening the file in r+ mode the file pointer is in beginning(0). After f.read(5) it will reach…

om bahetra
- 41
- 4
4
votes
4 answers
What is the word that means "directory" or "file"?
I'm trying to name an object that can be a file or a directory. What's the correct terminology for this?
I've considered
handle -> rejected, object is not a handle
address -> rejected, object is not an address
object -> rejected, too generic,…

Ben
- 54,723
- 49
- 178
- 224
4
votes
2 answers
How to use Tkinter to open file in folder using dropdown
I need help on how to make a button after I choose a folder in dropdown list.
For Example: I have 3 folders name "Folder 1","Folder 2" & "Folder 3". Inside "Folder 1", I have 5 excel(.xlsx) files. So I need help on how to read and display the data…

NAzira Nasir
- 57
- 6
4
votes
2 answers
Getting FILE* in a safe C++ way
Is there a way to obtain the FILE* handle of an opened file in a modern C++ way?.. I want to avoid using std::fopen from as I've been warned that it's potentially unsafe.
I tried checking if there's a way to retrieve FILE* from fstream but…

Jack Avante
- 1,405
- 1
- 15
- 32
4
votes
3 answers
Is there a way to check what part of my code leaves file handles open
Is there a way to track the python process to check where a file is being opened. I have too many files open when I use lsof on my running process but I'm not sure where they are being opened.
ls /proc/$pid/fd/ | wc -l
I suspect one of the…

Anand C U
- 885
- 9
- 29
4
votes
2 answers
Why are there extra spaces in the file after copying text from one file to another in C?
char c, cp;
FILE *input_file, *output_file;
input_file = fopen("d:\\input.txt","r");
output_file = fopen("d:\\output.txt", "w");
if(input_file==NULL){
printf("cannot open the input.txt file.");
exit(0);
}
if(output_file == NULL){
…

Nilmani Gautam
- 157
- 1
- 11
4
votes
1 answer
watchdog(python) - monitor only one file format and ignore everything else in 'PatternMatchingEventHandler'
I'm running code from this article and made some changes to monitor file creations/additions of only one format, that's .csv in a specified directory.
the problem now is:
My program breaks(stops monitoring, but keeps running), whenever the new…

Naveen Reddy Marthala
- 2,622
- 4
- 35
- 67