Questions tagged [writefile]

It is most often used when someone wants to add/insert content to file programmatically, such as using Javascript function writefile, one can be able to create and write content to a file.

e.g.

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!');
});
380 questions
3
votes
2 answers

json file I/O with pretty print format using gson in java?

I already know how gson works and also know how to enable pretty print. I want to use gson and not simplejson. The problem I had is that I wasn't able to create a file consisting of a List of Employee objects. I've seen every other java threads in…
MoeBoeMe
  • 93
  • 1
  • 8
3
votes
3 answers

Save byte array to file node JS

I want to save bytearray to a file in node js, for android I'm using the below code sample, can anyone suggest me the similar approach File file = new File(root, System.currentTimeMillis() + ".jpg"); if (file.exists()) …
Anuj J Pandey
  • 536
  • 1
  • 3
  • 15
3
votes
6 answers

How to check whether there's enough space before WriteFile in c in windows?

hPipe = CreateNamedPipe( lpszPipename, // pipe name PIPE_ACCESS_DUPLEX, // read/write access PIPE_TYPE_MESSAGE | // message type pipe PIPE_READMODE_MESSAGE | // message-read mode PIPE_WAIT, …
Alan
  • 4,669
  • 5
  • 28
  • 35
3
votes
1 answer

NodeJs writeFile writes "object object" in txt file instead of actual elements of objects

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

Read data from a text file and create an object

I need some help: I'm making a Supermarket simulation on Java, but I've got one problem, I have a text file (Stock.txt) where I have all the supermarket stock on it for example: 0-Bakery-Chocolate Cake-$12.5-250 1-Meat-Premium…
DkRckr12
  • 63
  • 1
  • 1
  • 3
3
votes
4 answers

Writing and Reading from a file at the same time

I've been trying to read and write from a file at the same time and I'm trying to substitute all the tabs in the content of text.txt to be turned into spaces. This is my code: int main() { FILE* filePtr = fopen("text.txt", "w+"); char c; c…
Anas Ayubi
  • 227
  • 1
  • 2
  • 9
3
votes
3 answers

Is it possible to "intercept" a 3rd party library's "WriteFile" operation

This is likely a long shot, but I thought I'd ask anyway. I'm using a document management system's API. They provide a "WriteFile" method to save a given document to disk. However, the library does not have a way to simply read a document into…
stout
  • 239
  • 1
  • 5
  • 8
3
votes
2 answers

Erlang, how can I create text file with newlines?

Somebody knows how can I append a new line in the text file in Erlang language? I want to save this list: Data = ["one", "two", "three"], into the text file with new lines: one two three I tried: write() -> Data = ["1","2","3"], Print =…
3
votes
1 answer

how to use php to write html tag to another html file?

I have two files. One is input.php, the other is output.html. Inner input.php file the code is like: loadHTMLFile($file); $elements = $doc->getElementsByTagName('head'); …
Kurt X
  • 207
  • 1
  • 6
  • 11
2
votes
2 answers

Trouble with Response.WriteFile / Response.BinaryWrite / Response.TransmitFile (ASP.NET)

I've got a simple web-page that generates a CSV file that I want the user to be able to download once its creation is complete. Here's a summary of my situation: The CSV file can be created in-memory or on disk. Doesn't matter to me. Once I'm done…
mbm29414
  • 11,300
  • 6
  • 52
  • 82
2
votes
1 answer

Reading the dynamic bitset written data from file cannot read the correct data

So I have a vector which has three numbers. 65, 66, and 67. I am converting these numbers from int to binary and appending them in a string. the string becomes 100000110000101000011 (65, 66, 67 respectively). I am writing this data into a file…
MIB
  • 57
  • 6
2
votes
2 answers

WriteFile returning error 1784

I am creating a program to populate a disk with a dummy file system. Currently, I am writing files of variable sizes using WriteFile. WriteFile(hFile, FileData, i * 1024, &dwWrote, NULL); err = GetLastError(); err returns #1784…
jscott
  • 295
  • 2
  • 5
  • 18
2
votes
2 answers

WriteFile failing depending on length of data to write?

EDIT Oddly enough, I've worked around this issue, but it's still annoying me. I worked around it by sending too-long writes, with padded zeroes; the code works but sends a few hundred unnecessary bytes. Specifically, I need to send exactly…
Sukasa
  • 1,600
  • 4
  • 17
  • 37
2
votes
0 answers

How to write to and read from a file in my assets folder in a flutter app?

I am trying to write to and read from a file that is in the assets folder in a flutter app. Generally, how should it be done? I tried the following approach:- void writeToFile(String data) async { final String filename = 'colors.json'; await…
iMujtaba8488
  • 231
  • 3
  • 6
2
votes
1 answer

WriteFile() blocks (writing from C++ client to C# server via named pipe )

I am stuck here, please help. I have a C# named pipe server, the pipe is created by: new NamedPipeServerStream(pipeName, PipeDirection.InOut, numThreads); In C++ I created the client like this: m_hPipe = CreateFile( strPipeName, …
Charlie
  • 704
  • 1
  • 13
  • 23
1 2
3
25 26