Questions tagged [writefile]

For questions about writing to a file. It could be referencing appending data, rewriting all existing content, or other related uses of functions that programmatically edit files. It is not limited to a certain language.

This tag is most often used when someone wants to add/insert content to a file programmatically. One example is in the Node JS function fs.writeFile, which is used to create files and write to them.

This is an example script which shows the usage of fs.writeFile to write a string to message.txt.

// Node JS

const fs = require('fs');
const data = new Uint8Array(Buffer.from('Hello Node.js'));

fs.writeFile('message.txt', data, (err) => {
  if (err) throw err;
  console.log('The file has been saved!');
});

Make sure to pair this tag with a language tag as is generally not specific enough to describe a complete question.

494 questions
0
votes
1 answer

reading and writing to s3 node js

I have a problem but I don't know how to solve it. I reading a file from s3, then I save it to a folder(downloads). After that, I read the file that I saved in the folder (that I saved in downloads) and re-size it + save it in a different folder…
user3488862
  • 1,329
  • 2
  • 12
  • 16
0
votes
1 answer

NetBeans 6.8 C++, files are being written and read in the wrong directory

When i run my project with the "Run main project" mode, my program writes the .txt file to my /home directory. I found this extremely odd, so I ran the program with "Debug main project" mode and it wrote the .txt file to the project directory. Is…
TheFuzz
  • 2,607
  • 6
  • 29
  • 48
0
votes
1 answer

Print JScrollPane content to pdf

I have found this code which transfer a JPanel to an image and then print it to PDF file but since I have that my JPanel inside a JScrollPane and does not contain any layout or dimensions because it depends on the JScrollPane layout so I can't print…
Hussein
  • 653
  • 3
  • 10
  • 28
0
votes
2 answers

Unable to create a text file in windows form, getting error 'System.ArgumentException'

I've made a button so when I click it, it opens up a directory from which I can create a text file, I click the button, it opens the directory fine, I can name the text file what I want and click save, but then I get an error saying "An unhandled…
Anthony
  • 61
  • 1
  • 6
0
votes
0 answers

writeFile is only writing one statement/log

function querydb() { cursor = dbConnection.collection("logs").find(queryObj).limit(parseInt(valueList[1])); /*Either decide here to foreach for file or for console OR...*/ cursor.forEach(function(item) { /*Decide here whether to write to…
0
votes
5 answers

Python write to txt file at specific line

I am creating a python stock system in ,which I need to allow a user to enter a product code and enter their quantity and the software checks a txt file. It checks whether the product is found and whether their is enough of them. I am stuck trying…
0
votes
2 answers

How can I write an EDN line by line? (spit, seq of hashmaps)

I have data like that tab = ({"123" data} {"456" data} ... (whatever, it is a lazy sequence of hashmaps). I want to write it into an edn file line by line, so I did this (map (fn[x] (spit "test.edn" x :append true)) tab) The problem is that I…
Joseph Yourine
  • 1,301
  • 1
  • 8
  • 18
0
votes
0 answers

swift array read/write data to file

I'd like to read data from an array and write data to a file and viceversa. The file itself has a known path. The BTTableCell class manages and populates the tableView. I'm using dati_Riga class in order to have a single array. I thought it would be…
0
votes
1 answer

do writefile function twice

bool sendMessageToGraphics(char* msg) { //char ea[] = "SSS"; char* chRequest = msg; // Client -> Server DWORD cbBytesWritten, cbRequestBytes; // Send one message to the pipe. cbRequestBytes =…
ronbob
  • 13
  • 6
0
votes
1 answer

C++ Unable to read from file and write to file in the same run

I'm attempting to read an inventory in from 3 files in one function and then rewrite those 3 files in another. When I try each of these functions individually, they both seem to work. But when I use both of them in the same run, the text files…
daviddorsey4
  • 122
  • 1
  • 10
0
votes
2 answers

WinAPI Write "Edit" Dialog to Pipe (Error: Stack around variable 'x' was corrupted)

It seems I figured out most of my problems by simply multi-threading my application! However, I am running into a little bit of an error: "Stack around variable 'x' was corrupted." It works properly (after hitting abort on the Debug Error), but…
RageD
  • 6,693
  • 4
  • 30
  • 37
0
votes
1 answer

Using python to achieve replace function

I am trying to operate some file like this: *sline 1, 1.0, 2.23 2, 1.0, 9.98 3, 2.0, 10.00 *eline Now I have a list, which contain data like this: datalist = [[1,1.0,2.0],[3,2.0,2.0]] I want to put the value which belong to datalist to replace the…
GuangWu
  • 143
  • 1
  • 1
  • 6
0
votes
0 answers

LaTeX fp-package increase counter when compiling

So i am reading a number from a file and i'd like to increase it and write it back to the file each time i compile the .tex-file. The problem is that the number is not increased by +1 as i scripted it, instead it is raised by 4 when i'm reading the…
Mago
  • 67
  • 8
0
votes
1 answer

Error Vector subscript out of range

I believe my error is within my writeline function, when I attempt to write the contents of the vector to the new file using a while loop. //Read from txt file, write to new text…
mcdito13
  • 191
  • 1
  • 3
  • 13
0
votes
1 answer

Writing JSON data to file in python

I'm not quite sure on how you write a JSON so can you please help me, i'm trying to make this with JSON in python. Here's the pseudo-code binary_students = json(students) write_to_the_file_system(binary_students) I'm not quite understanding it,…