writefile

Serial port WriteFile() freeze

I have a simple application, which should send a single byte to a serial port once a minute. But sometimes, from some strange reason, it freezes somewhere in the WriteFile() function. Both sw and hw flow controls are turned off. I've googled some stuff about pending read operations performed from another threads, but I believe this is no...

sprintf() and WriteFile() affecting string Buffer

I have a very weird problem which I cannot seem to figure out. Unfortunately, I'm not even sure how to describe it without describing my entire application. What I am trying to do is: 1) read a byte from the serial port 2) store each char into tagBuffer as they are read 3) run a query using tagBuffer to see what type of tag it is (bo...

Writing files to USB stick causes file corruption/lockup on surprise removal

I'm writing a background application to copy files in a loop to a USB stick with the "Optimize for quick removal" policy set. However, if the stick is removed part way through this process (specifically in the WriteFile() call below, which returns ERROR FILE NOT FOUND) the application hangs, the drive is then permanently inaccessible fro...

problem writing a NSMutableArray to file in cocoa

A real beginners question. I have a NSView subclass in which I create a NSMutableArray containing NSValues. When I want to write the array to a file using writetofile:atomatically: the file is created but it contains none of the NSValues that the mutable array does contain. Does anyone know how I successfully can write this mutable array...

Write a circular file in c++

Hi, I need to write a circular file in c++. The program has to write lines in a file and when the code reaches a maximum number of lines, it must overwrite the lines in the beginning of the file. Anyone have any idea? Thanks ...

saving file to network

I have a file that's about 7 MB that saves to my local share in a matter of seconds. However, saving that file to a network location takes minutes. I'm wondering what I can do to speed this up. Here are my current options: Save the data to a temporary file on the local machine, then copy the temporary file over to the network path. ...

Java - open existing file or create one if doesn't exist using IO streams

I was following instructions from a Java website (http://java.sun.com/docs/books/tutorial/essential/io/file.html#createStream) on creating or writing a file using an IO stream. However, the code it provides seems to be broken in multiple places: import static java.nio.file.StandardOpenOption.*; Path logfile = ...; //Convert the string...

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 <- read.table("http://dpaste.com/89376/plain/",fill=T); problist <- c(); for (lmer in 1:10) { meanl <- lmer; stdevl <- (0.17*sqrt(l...

Why does .NET not clear errors internally?

I am running the following scenerio: SafeFileHandle handle = Win32API.CreateFile((deviceName + "\\" + pipeName), DesiredAccess.GENERIC_WRITE | DesiredAccess.GENERIC_READ, ShareMode.FILE_SHARE_WRITE | ShareMode.FILE_SHARE_READ, IntPtr.Zero, ...

Unable to write file in C++

I'm trying to to the most basic of things .... write a file in C++, but the file is not being written. I don't get any errors either. Maybe I'm missing something obvious ... or what? I thought there was something wrong with my code, but I also tried a sample I found on the net and still no file is created. This is the code: ofstream...

Remove Characters from EOF while Writing to File in Matlab

In Matlab, after creating a certain number of lines and printing them to a file, I have the need to delete a line and rewrite the rest of the data to that same file. When I do so, the new data overwrites the previous data, but since the data is shorter than the original, there are still remnants of the original data. Does anyone have a...

WriteFile vs TransmitFile for large files that need to be deleted from the server after transfer

I have to trigger user downloads of large files to a webbrowser, where I create the file to transfer on the server, then delete it immediately afterwards. I've found enough examples to see that I should probably use Response.TransmitFile or Response.WriteFile... but have heard there are problems with both: WriteFile is synchronous, but...

Simple Mailslot program not working?

Using the client and server examples found here: http://www.winsocketdotnetworkprogramming.com/winsock2programming/winsock2advancedmailslot14.html Compiling them with VS2008, running the server and then "client Myslot" I keep getting "WriteFail failed with error 53." Anyone have any ideas? Links to other Mailslot examples are also welcom...

Saving CSV in cocoa

Hello, 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 this: Results,,,,,,,,,,,, ,,,,,,,,,,,, A,10,,,,,,,,,,, B,10,,,,,,,,,,, C,10,,,,,,,,,,, D,10,,,,,,,,,,, E,10,,,,,,,,,,, So to replicate this in cocoa I used: NSString *CVSData = [NSString stringWithF...

Is WriteFile atomic ?

I'm designing a system that will write time series data to a file. The data is blocks of 8 bytes divided into two 4 bytes parts, time and payload. According to MSDN the WriteFile function is atomic ( http://msdn.microsoft.com/en-us/library/aa365747(VS.85).aspx ), if the data written is less then a sector in size. Since the file will o...

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 memory. My only option, it seems, is to write to disk, then read it back in again. I'm won...

How to access files in Java ME

I want to access the files encircled in this screenshot. What path should I use? This is for my JavaME application. file:///ParseExample/service1.xml doesn't seem to be the right one. http://www.fileden.com/files/2010/5/28/2872707//projectfiles.JPG Edit: Here is my code: FileConnection fconn = (FileConnection) Connector.open("file:///...

WinAPI Write "Edit" Dialog to Pipe (Error: Stack around variable 'x' was corrupted)

Hello everyone. It seems I figured out most of my problems by simply multi-threading my application! However, I am running into a little bit of an error: "Stack around variable 'x' was corrupted." It works properly (after hitting abort on the Debug Error), but obviously I cannot have an error everytime someone runs the application. So he...

Why the following c++ snippet gives exception?

VIDEOINFOHEADER *pVih = (VIDEOINFOHEADER*)pmtConfig->pbFormat;; ... WriteFile( hHandle, pVih, sizeof(VIDEOINFOHEADER), NULL, NULL ); Through debugging I found WriteFile reports exception, how to solve it? ...

NetBeans 6.8 C++, files are being written and read in the wrong directory...

When i run my project with the "Run main project" mode, my program writes the .txt file to my /home directory. I found this extremely odd, so I ran the program with "Debug main project" mode and it wrote the .txt file to the project directory. Is there a setting in options that will fix this so both modes will write the file to the proje...