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

WriteFile from array^ class

I am trying write into text file from textBox in VC++ but written data in file is not right and also every time is different. DWORD wmWritten; textBox1->Text = "7.5"; array^ char_array1 = textBox1->Text->ToCharArray(); HANDLE hFile =…
0
votes
1 answer

Android read/write local file (NullPointerException)?

I'm using simple code for read/write oneLine string to local file. And it works well, until I put Read/write_file_operations in another class. Now this code get null pointer exception, I think something wrong with Context, but I don't know…
0
votes
1 answer

How to make sure data is flushed to HDD (not buffered) on file IO (WriteFile())

During a lengthy and possibly system stressful operation I update a file from time to time via a File Handle and WriteFile I noticed that when I right mouse click the file and ask for its properties in Windows I don't see it has been updated at all.…
Peter
  • 1,334
  • 12
  • 28
0
votes
2 answers

How to save/read arrays of data in a file (C++)

i'm using a code which computes SIFT descriptors from an image. I have to process each frame from a video and store the sequence of each computed descriptor. For each image the descriptor is made by two arrays: Frames = (double*)realloc(Frames, 4 *…
user2614596
  • 630
  • 2
  • 11
  • 30
0
votes
1 answer

node-webkit can not write file in app.nw

var jf = require('jsonfile'); jf.writeFile("./setting.json", newSettings, function(err) { if (err){ console.log("writing file err: ", err); } else { console.log("setting saved successfully."); } }); Above code reports…
Russj
  • 697
  • 1
  • 10
  • 22
0
votes
1 answer

LPOVERLAPPED_COMPLETION_ROUTINE is incompatible with function

I want to asynchronously write data to file using WriteFileEx from winapi, but I have a problem with callback. I'm getting follow error: an argument of type "void (*) (DWORD dwErrorCode, DWORD dwNumberOfBytesTransfered, LPOVERLAPPED lpOverlapped)"…
Mike_Device
  • 634
  • 2
  • 8
  • 25
0
votes
0 answers

Writefile called from a timer event cause error access_denied

I made an APP that read the ADC value from a PIC using USB HID custom, the first test was to use a button to read the value and pass the read value to a progress bar and a textbox, that worked fine: private void btnRead_Click(object sender,…
Sodor
  • 55
  • 4
0
votes
2 answers

Java wont Write all to file

I'm trying to do an assignment and I can't figure out why it won't write all of the collected data to a text file. Basically I need to read one .txt file called 'marks', output it (which it does) and then sort it into two files - if the grade is…
Taj Melic
  • 33
  • 6
0
votes
2 answers

How to use Win32 API to specify directory to write file to using WriteFile?

I've used the following to get a handle to a file: char *filePathAndName = "C:\Projects\pic.bmp"; HANDLE hFile = CreateFile(_T(filePathAndName),GENERIC_WRITE, 0, NULL, CREATE_ALWAYS, FILE_ATTRIBUTE_NORMAL, NULL); and I've used the following to…
user3731622
  • 4,844
  • 8
  • 45
  • 84
0
votes
3 answers

how to insert line in file

I want to insert a line in a file. like below, insert '111' once 'AAA' appears original file AAA BBB CCC AAA DDD AAA and I want the result to be : AAA 111 BBB CCC AAA 111 DDD AAA 111 Here are my codes with open(outfile, 'r+') as outfile: …
rankthefirst
  • 1,370
  • 2
  • 14
  • 26
0
votes
1 answer

Changing file name, when fprintf reaches an N number of lines

i hope someone can help me, how to achieve this. I have a code that writes permutation to a file. i realized that my output file is very big. i would like to know how to be able to split change the name of the text when a number of lines has been…
0
votes
2 answers

Trying to write in one file using 2 functions

I have a project which requires me to print data in an output file using two functions. One function prints the values of a vector, and the other prints the values of an array. However, the second function that is called in main overwrites whatever…
iEclipse
  • 13
  • 5
0
votes
2 answers

matlab : permutation of two lists based on criteria

i hope someone can help me, how to achieve this. I have to files with list of data, i am trying to calculate possible permutations between the two lists and save them to a new file. i realized that my output file is very big ( more than 30 Gb ). i…
0
votes
1 answer

Saving CSV in cocoa

I need to make a cvs file in cocoa. To see how to set it up I created one in Numbers and opened it with text edit it looked like…
nosedive25
  • 2,477
  • 5
  • 30
  • 45
0
votes
2 answers

Dart string interpolation through console run script

I'm using Dart to generate controller classes into the project framework using a script I've made in the tool directory. The script is run using the following terminal command (whilst in the project directory of course): dart…
Will Squire
  • 6,127
  • 7
  • 45
  • 57