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

Writing a file from Jsoup document on Andorid and search for specific token

I am very new to android and am trying to create an app for a school project that fetches a piece of information from a website. I am using Jsoup to creat a document and then I try to store the html from the site as a file locally. The number I want…
2
votes
1 answer

$cordovaFile.writeFile writes blank file

I used writeFile(path, file, data, replace) method in $cordovaFile to write new file(pdf, jpg, text ). as a data I got data stream from restful service ..(it looks like %PDF-1.5↵%����↵1 0 obj↵..) The problem is I can write a file but it opens as…
Uditha Prasad
  • 695
  • 5
  • 13
2
votes
0 answers

Write/Read sparseVector of eigen to file

I just folow this : How to write/read an Eigen matrix from binary file namespace Eigen{ template void write_binary(const char* filename, const Matrix& matrix){ std::ofstream out(filename,ios::out | ios::binary | ios::trunc); …
user2165656
  • 445
  • 1
  • 3
  • 11
2
votes
3 answers

Write performance of a file c++

I need to write a file in c++. The content is token from a while loop so now I'm writing it line by line. Now I'm thinking that I can improve the writing time saving all the content in a variable and then write the file. Does someone know which of…
Carme
  • 141
  • 1
  • 9
2
votes
2 answers

Writing to a file in python

In the following code I simply want to write the data I obtained from flickr in a neat way in a file for use later. However although the console throws no errors, nothing is being written to my file. Can anyone help me out with this, thank you in…
RyanKilkelly
  • 279
  • 1
  • 4
  • 15
2
votes
1 answer

Use PHP fwrite to write php file

I'm building a CMS and I'm stuck on this problem. I need to write a simple php file for every page and I need to pass an ID and the include function. Here is my code to write the file: $filename=mysqli_fetch_array($query))['pagename']; …
Cr1xus
  • 427
  • 3
  • 20
2
votes
2 answers

How to read and write many objects (or any data) to a buffer?

I am writing a program to save some object (struct) to a buffer. I don't have experiment to write many objects to buffer and read these objects from the buffer. Any help would be appreciated. My code can write one item to object and I want write…
Mozart
  • 97
  • 1
  • 1
  • 9
2
votes
1 answer

Verify if previous line have same string than current line and sum value of another column

What i'm trying to do is that such script reads the current…
Jontexas
  • 121
  • 8
2
votes
1 answer

hidapi: Sending packet smaller than caps.OutputReportByteLength

I am working with a device (the wiimote) that takes commands through the DATA pipe, and only accepts command packets that are EXACTLY as long as the command itself. For example, it will accept: 0x11 0x10 but it will not accept: 0x11 0x10 0x00 0x00…
Flafla2
  • 545
  • 7
  • 12
2
votes
2 answers

On Data Frame: Writing to File and Naming Binded Vector in R

I have a data that looks like this. And my code below simply compute some value and binds the output vector to the original data frames. options(width=200) args<-commandArgs(trailingOnly=FALSE) dat <-…
neversaint
  • 60,904
  • 137
  • 310
  • 477
2
votes
2 answers

WritePrivateProfileString is not adding property to the end

I am writing some properties in a ini file using WritePrivateProfileString function and everything works fine but when I add text with multiple lines, there is a problem. Here is the code and output. WritePrivateProfileString(_T("General"),…
fhnaseer
  • 7,159
  • 16
  • 60
  • 112
2
votes
2 answers

WriteFile hook doesn't catch writing to file operation

I have an app, which writes to files some text data. What I'm trying to do is to hook the writing process. I hooked with MS Detours, CreateFile, WriteFile and WriteFileEx functions. CreateFile catches creation/opening of these text files properly,…
Jakub Matczak
  • 15,341
  • 5
  • 46
  • 64
2
votes
2 answers

Writing to file, file being used by another process

Alright, so I can't figure out why I can't write to a file. It says it's being used by another process. Here's the error (IOException was unhandled): The process cannot access the file 'C:\Temp\TempFile.cfg' because it is being used by another…
Muhnamana
  • 1,014
  • 13
  • 34
  • 57
2
votes
2 answers

Prelude.writeFile with a Chinese file name

I'm testing something that like to output content to file, which has a Chinese name. The file would be created successfully with right content but not file name. I take a look at the function writeFile^1 and it represents file name using String. So…
Simon
  • 2,990
  • 3
  • 20
  • 17
1
vote
2 answers

Write Contents in a text file in a tabular order using C#

I want to write contents into a text file from a DatagridView in my application. In my text file, I would like to follow a format like Column1 Column2 Column3 [Cell1] [Cell2] [Cell3] [Cell1] …
stack_pointer is EXTINCT
  • 2,263
  • 12
  • 49
  • 59