write

Which is faster, writing raw data to a drive, or writing to a file?

I need to write data into drive. I have two options: write raw sectors.(_write(handle, pBuffer, size);) write into a file (fwrite(pBuffer, size, count, pFile);) Which way is faster? I expected the raw sector writing function, _write, to be more efficient. However, my test result failed! fwrite is faster. _write costs longer time. I'v...

FileStream.Write not Writing to File

I'm passing some Base64 encoded strings through WCF, and I'm attempting to write them to a file. However, despite the fact that my FileStream object has a Length greater than 0, my file on disk remains empty. FileStream fs = new FileStream(Config.Instance.SharedSettings.SaveDir + StudyInstance.StudyId + "\\tmp.ext", FileMode.Create); E...

C# locking read while writing binary file

Hi, I am trying to figure out how to write a binary file with a FileStream and BinaryWriter, and keep the file locked for read while I am writing. I specifically dont want other applications/processes to be able to read from the while while its being written to. //code to declare ba as a byte array //dpath is the path to the file Fi...

PHP file writing optimization

EDIT: Optimization results at end of this question! hi, i have a following code to first scan files in a specific folder and then read every file line by line and after numerous "if...else if" write new modified file to another folder with the name name as it was when opened. The problem is that writing a file line by line seems to be ...

How to read/write nodes and child nodes from xml file in c# maybe using xpath?

Hello, Maybe somebody could help me. I need a two methods. The first should open a xml file and get all nodes with the given parameter ie.: XML file (file.xml): <Menu id="1" Name="myMenu"> <MenuItem Header="Header 1" Name="header1" /> <MenuItem Header="Header 2" Name="header2"> <MenuItem Header="subHeader 2.1" Name="header2_...

Reading and writing to console in Java

What is the most efficient class to use to read from and write to console in Java? ...

Need to write at beginning of file with PHP

I'm making this program and I'm trying to find out how to write data to the beginning of a file rather than the end. "a"/append only writes to the end, how can I make it write to the beginning? Because "r+" does it but overwrites the previous data. $datab = fopen('database.txt', "r+"); Here is my whole file: <!DOCTYPE HTML PUBLIC "-/...

Java: Why isn't my file writing working?

I'm trying to write a file from my Java program, but nothing happens. I'm not getting any exceptions or errors, it's just silently failing. try { File outputFile = new File(args[args.length - 1]); outputFile.delete(); outputFile.createNewFile(); PrintStream output = new PrintStream...

How to write into a file in PHP?

Hello everybody!!! I have this script on one free PHP-suppoting server: <html> <body> <?php $file = fopen("lidn.txt","a"); fclose($file); ?> </body> </html> it does create the lidn.txt file, but it's empty. I want to create a file and to write something into it, for example this line "Cats chase mice", how can I do it? ...

need help writing hexadecimals to an exe file

can somone tell me how to write these hexadecimals to an exe file while still having it exec 4D 5A 50 00 02 00 00 00 04 00 0F 00 FF FF 00 00 B8 00 00 00 00 00 00 00 40 00 1A 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 01 00 00 BA 10 00 0E 1F B4 09 CD 21 B8 01 4C CD 21 90 90...

Java: write an array into a text file

Hi, I'm trying to write a matrix into a text file. In order to do that I'd like to know how to write an array into a line in the text file. I'll give an example: int [] array = {1 2 3 4}; I want to have this array in text file in the format: 1 2 3 4 and not in the format: 1 2 3 4 Can you help me with that? Thanks a lot ...

What's the different between Console.Write("H") and Console.Write('H') in C#. thanks.

Hello all. What's the different between Console.Write("H") and Console.Write('H') in C#. thanks. :-) ...

How to save double to file in python?

Let's say I need to save a matrix(each line corresponds one row) that could be loaded from fortran later. What method should I prefer? Is converting everything to string is the only one approach? ...

How to safely write to a file?

Imagine you have a library for working with some sort of XML file or configuration file. The library reads the whole file into memory and provides methods for editing the content. When you are done manipulating the content you can call a write to save the content back to file. The question is how to do this in a safe way. Overwriting th...

Go - How to read/write to file?

I've been trying to learn Go / Golang on my own, but I've been stumped on trying read and write to ordinary files. I can get as far as: inFile,_ := os.Open(INFILE,0,0); but actually getting the content of the file doesn't make sense, since the read function takes a []byte as a parameter?? func (file *File) Read(b []byte) (n int, err E...

Create XML file dynamically in Iphone

Hi I want to create a xml file dynamically for my Iphone application. I tried it by using NSXMLDocument but NSXMLDocument is not declared in iphone application. Please help me in doing so. Thanks Gaurav ...

[PHP] Retrieving and writing a file to system

What's the simplest way for me, in PHP, to: Retrieve a file from an external URL (http://test.com/thisfile) If successful, delete local file /root/xml/test.xml Rename downloaded file to test.xml Write new file to /root/xml/ folder This will be a private script, so security or error handling are not important concerns. ...

Writing to a Text File (PHP)

hey Guys, I know this question is probably straightfoward but I'm new to php and programming... I want to write the results of a recursive search to a text file, and also ensuring that any other search performed will not overwrite the exisiting data, but add to it. here is my code: <?php $it = new RecursiveDirectoryIterator("L:\fol...

How do I write a text file in the same format that it is read in MATLAB?

I have asked a related question in the past and I know how to read the file thanks to the help of the experts here. Now I have a new problem. I first read the data from the file like so: fid = fopen('D:\file.txt', 'rt'); a = textscan(fid, '%s %f %f %f %f %f %f', ... 'Delimiter',',', 'CollectOutput',1, 'HeaderLines',1); fclo...

C# write multi lines to cs file.

Hello. I googled and found the solution at MSDN. // Compose a string that consists of three lines. string lines = "First line.\r\nSecond line.\r\nThird line."; // Write the string to a file. System.IO.StreamWriter file = new System.IO.StreamWriter("c:\\test.txt"); file.WriteLine(lines); file.Close(); How to extend the lines to comp...