Questions tagged [file-handling]

file-handling is an abstraction of common actions such as creating, opening, closing, reading, updating, writing, comparing and deleting files

2915 questions
4
votes
2 answers

How can read Minecraft .mca files so that in python I can extract individual blocks?

I can't find a way of reading the Minecraft world files in a way that i could use in python I've looked around the internet but can find no tutorials and only a few libraries that claim that they can do this but never actually work from nbt import…
Robert Lucas
  • 61
  • 1
  • 12
4
votes
1 answer

Windows C Run-Time _close(fd) not closing file

We have a problem in production with a Windows application written in a mix of C and C++ where MoveFileEx occationally reports "The process cannot access the file because it is being used by another process.". The problem is rare but recently we…
4
votes
1 answer

Cannot recover original image file from encrypted file after decryption in Python3

I am writing a script to encrypt files in Python using RSA. I have successfully encrypted the original file and saved it to another file. When decrypting the encrypted file, the code is running, but when I am opening the image it is showing that the…
4
votes
1 answer

Python doesn't find a file within a Docker container

I have an issue that my python program doesen't find a given folder in ubuntu with in a docker container. First I build my docker container and then I run it which goes without problems until my programm don't find a file. I'm working on a…
FoldFence
  • 2,674
  • 4
  • 33
  • 57
4
votes
1 answer

Is there a standard file save and swap pattern?

Our product holds a write-exclusive file handle on each opened document file to ensure that we have exclusive write control over the file. Hence, Windows won't allow any other process to do more than read from the file, nor can the file be deleted…
Mordachai
  • 9,412
  • 6
  • 60
  • 112
4
votes
1 answer

Change Erlang file handle limit?

I'm running into trouble with an Erlang OTP + Cowboy app that does not allow me to open enough files simultaneously. How do I change the number of open file handles allowed in the BEAM? Potentially, I'll need about 500 small text files open at the…
Chris W
  • 289
  • 1
  • 12
4
votes
1 answer

whether tellp() not defined in append mode?

I was experimenting with file pointers in C++. In below code, the result obtained is 0, 30, 10 and 12. So it means that tellp() does not give correct result in append mode if we do seekp(). I was expecting tellp() to give me 32 after seekp() and…
Rajesh
  • 1,085
  • 1
  • 12
  • 25
4
votes
2 answers

initial value of file pointer position returned by ftell() in append mode

I was looking at SO post fseek does not work when file is opened in "a" (append) mode and I got a doubt regarding initial value of file pointer returned by ftell() when we open the file in "a" mode. I tried below code with file1.txt containing data…
Rajesh
  • 1,085
  • 1
  • 12
  • 25
4
votes
1 answer

After StreamWriter.WriteLine(), FileStream.SetLength(0) does not empty the file

I found a strange problem with FileStream.SetLength(0). When writing first something to a stream and then calling SetLength(0), the content of the previous write still gets written to the file: var fileName = "test.txt"; using (var fileStream = new…
Peter Huber
  • 3,052
  • 2
  • 30
  • 42
4
votes
4 answers

Python remove brackets and String quotation marks from array

myArray = [] textFile = open("file.txt") lines = textFile.readlines() for line in lines: myArray.append(line.split(" ")) print (myArray) This code outputs [['a\n'], ['b\n'], ['c\n'], ['d']] What would I need to do to make it output a, b, c, d
4
votes
5 answers

How to count number of .txt files in a directory in PHP?

I'm working on an IMDB style website and I need to dynamically find the amount of reviews for a movie. The reviews are stored in a folder called /moviefiles/moviename/review[*].txt where the [*] is the number that the review is. Basically I need to…
Dakota Wagner
  • 117
  • 2
  • 15
4
votes
2 answers

Unable to understand - reading characters from files in C

I have just started learning file handling in C, and wondered if I could perform mathematical calculations by reading input from a file, here is the code for just reading the characters and displaying on the console : int main(void) { FILE *p; …
CaptainDaVinci
  • 975
  • 7
  • 23
4
votes
1 answer

How to Show Word Document File in Browser instead of downloading Spring MVC?

HI everyone i am doing file handling in my spring MVC Application, i need to display Word file (.doc, .docx) file in my browser instead of downloading.. i am using this code for displaying file in browser,.. response.setHeader("Content-Disposition",…
Ahmad
  • 1,462
  • 5
  • 17
  • 40
4
votes
1 answer

on a Web Setup, how do I exclude all .pdb files?

In a sample solution on Visual Studio 2008, let's say, I have this: myWebSite project (web site project) myLibrary project (library project) myWebsiteDeploy project (web deployment project) myWebSetup project (web setup project) inside myWebSite…
balexandre
  • 73,608
  • 45
  • 233
  • 342
4
votes
4 answers

How should I check if BufferedWriter is already closed?

In android, I am writing a file on clicking a button and on clicking next time, it saves the file and closes the buffered writer. But, I also want to implement functionality to close the buffered writer in onDestroy function. Before that I need to…