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
-1
votes
1 answer

How to Choose the location to save the download files when forcing file download in Codeigniter?

Now, the CSV file is exported in reports folder. Instead i want the browser to ask where to export the file. so that i can export the file in desired location of client machine and avoid storing those files in server (i.e)reports…
J Ramesh Fernandez
  • 309
  • 1
  • 8
  • 22
-1
votes
1 answer

Passing a function and its size to WriteFile

As a learning exercise, I'm writing a program that outputs a DLL at run-time. I've written the PE header and have successfully written the DOS header, NT header, optional section header and the .text section header to a file using WriteFile,…
Hugh McMaster
  • 319
  • 3
  • 10
-1
votes
2 answers

C programming: Create and write 2D array of files as function

I have a very long program, which I am trying to shorten. I frequently write 2d file arrays, but I repeat this process dozens of times throughout my program, so I am trying to write as a function to reduce mistakes on my part and make the code…
con
  • 5,767
  • 8
  • 33
  • 62
-1
votes
1 answer

read and write in binary files java.io.EOFException

i want program that reads the information from the file items.dat, and then creates another file named availableItems.dat containing the information (barcode, quantity, price) of only the available items (having quantity more than 0) followed by the…
swa
  • 9
  • 4
-1
votes
2 answers

Creating a file and writing something into it does not work how I wanted it

I write the following code: #include #include "stdbool.h" #include #include #include #include #include #define MAX_SIZE 100 …
user3097712
  • 1,565
  • 6
  • 27
  • 49
-1
votes
1 answer

writeFile() method doesn't write all lines to text file [JAVA]

I am trying to write the contents of an arraylist to a text file. I am partially able to do this with my newbie coding skills, however at the moment it only writes the first line out of 48 lines to the text file. I would assume that this might be…
rr0102
  • 19
  • 5
-1
votes
2 answers

Update: Python average income reading and writing files

I was writing a code to find the average household income, and how many families are below poverty line. this is my code so far def povertyLevel(): inFile = open('program10.txt', 'r') outFile = open('program10-out.txt',…
-1
votes
2 answers

C++ WriteFile only writing 4 bytes

Here's what I'm trying to achieve; I'm hooking onto the HttpSendRequest function (on Xbox it's XHttp) and trying dump the certificate that's in pcszHeaders which has the size of 0x1F0E. Now the problem; it only seems to write 4 bytes, I've even…
Corona
  • 375
  • 5
  • 21
-2
votes
1 answer

How to write to file in GitHub Actions using Python?

I want to write a text to file using GitHub Actions but I don't know how to do it. I've tried: def write(path, text): file = open(path, 'w') file.write(text) file.close() but nothing has changed. But if I run it on local machine it is…
Cat_125
  • 1
  • 2
-2
votes
2 answers

How to create a single csv log file as long as the program runs in C#?

At the moment my program creates a new log file every hour with file name as current date and current hour. There are two disadvantages For instance, I run the program for 3 hours and 20 minutes and want to have the csv log data of that duration…
EverActive
  • 15
  • 4
-2
votes
2 answers

saving file with format

Hi guys I am trying to save my file in python... I dont know how to do it.. It came out the save file to be like this : 506882122734561843241851186242872 What I am trying to do is ["50688", "212273", "4561843", "241851", "18624", "2872"] with…
-2
votes
1 answer

How to read multiple input files and write into a new file in txt and excel in C++?

I used to run a calculation by reading from 1 txt file ("1_Hello.txt"), calculate and output by functions, and write the output into a new txt file. But now I have 5000 txt files ("1_Hello.txt" to "5000_Hello.txt"). I want to read all 5000 txt…
kingsley
  • 27
  • 5
-2
votes
2 answers

Want to write to a file but I get the failure "Access to the path xy denied."

I am trying to write the data of a heartrate puls belt to a file. Everytime I start the programm it says "Access to the path denied". The file is not "read-only". I also tried this from another question: File.SetAttributes(file,…
Leo Ge
  • 31
  • 2
-2
votes
3 answers

[WIN API]Why sharing a same HANDLE of WriteFile(sync) and ReadFile(sync) cause ReadFile error?

I've search the MSDN but did not find any information about sharing a same HANDLE with both WriteFile and ReadFile. NOTE:I did not use create_always flag, so there's no chance for the file being replaced with null file. The reason I tried to use the…
Lynch Chen
  • 178
  • 2
  • 16
-2
votes
2 answers

C# - Write line if line doesn't exist

I'm trying to write a line in a CSV file as a string if the exact string doesn't exist in the CSV file already. My code works fine for me when I don't check if the line exists. My current code looks as the following and just doesn't seem to…
Nico Roos
  • 11
  • 1
1 2 3
32
33