file-io

C#: capture data, display to user, save to disk, upload to database: BEST approach

I have a program that captures live data from a piece of hardware on a set interval. The data is returned as XML. There are several things I would like to do with this data (in order): -display it to user -save it to disk -eventually, upload it to database My current approach is to take the XML, parse it into a hashtable so I can disp...

Creating big file on Windows

Hi, I need to create big relatively big (1-8 GB) files. What is the fastest way to do so on Windows using C or C++ ? I need to create them on the fly and the speed is really an issue. File will be used for storage emulation i.e will be access randomly in different offsets and i need that all storage will be preallocate but not initia...

Formating file on windows

Hi, Following my question about creating files. After fast creation of large file, now i need to create a file system on this file. How can i create something like Loop device on Linux. After this i guess formatting will be really easy. Any alternative method (instead mounting) for formatting file to different FAT (12/32) and ext3 are ...

Are there limitations on the amount of data you can redirect to a file under Windows (XP/2003)?

I'm driving a web services load test using a system of WSF, VBS and JavaScript scripts. The load driver is running on my workstation, sending requests to a remote application server. I'm using WScript.StdOut.Write in the driver script to write results, and just redirecting the output to a text file when I run the test: cscript //nologo ...

how to set the default encoding in windows XP ?

Hello, im trying to open a file using StreamReader and ive to set a Encoding, but i want it to take the Default Windows Encoding... how can i change my windows Encoding ??? ...

Locking a file while copying using Commons IO

I am using the Apache Commons IO: FileUtils.copyFileToDirectory(srcFile, destDir) How do I make Windows lock the destination file during copy? Windows locks the file correctly if I use: Runtime.getRuntime().exec( "cmd /c copy /Y \"" + srcFile.getCanonicalPath() + "\" \"" + destDir.getCanonicalPath() + "\"")...

Unexpected output copying file in C

In another question, the accepted answer shows a method for reading the contents of a file into memory. I have been trying to use this method to read in the content of a text file and then copy it to a new file. When I write the contents of the buffer to the new file, however, there is always some extra garbage at the end of the file. ...

Is std::ifstream significantly slower than FILE?

I've been informed that my library is slower than it should be, on the order of 30+ times too slow parsing a particular file (text file, size 326 kb). The user suggested that it may be that I'm using std::ifstream (presumably instead of FILE). I'd rather not blindly rewrite, so I thought I'd check here first, since my guess would be the...

Create temp dir that is globally known and that gets automagically removed (C++)?

In C++, I have a few functions that need to write to a temp directory. Ideally, only one temp directory gets created that they all write to (to minimize I/O overhead). That directory should be automagically removed when the program exits. However, I don't want to deal with creation and removal of the temp directory in the main function ...

Creating files in C++

I want to create a file using C++, but I have no idea how to do it. For example I want to create a text file named Hello.txt. Can anyone help me? ...

Blocking read from FIFO via ifstream object

I open a FIFO file as ifstream. As soon as the object is created the thread is blocked until I send something into the FIFO (which is OK for me). I then call getline() to get the data from stream. How do I read-block the thread again until more data is written into FIFO file? Thanks ...

Can .NET load and parse a properties file equivalent to Java Properties class?

Is there an easy way in C# to read a properties file that has each property on a separate line followed by an equals sign and the value, such as the following: ServerName=prod-srv1 Port=8888 CustomProperty=Any value In Java, the Properties class handles this parsing easily: Properties myProperties=new Properties(); FileInputStream fi...

How to Check Path is existing or not in java?

Hi All: I have a java program which take path as argument. I want to check whether given path is existing or not before doing other validation. Eg: If i give a path D:\Log\Sample which is not not exist, it has to throw filenotfound exception. How can i do that? ...

Storing and Retrieving Dynamically Changing Structures

I am creating a game using Allegro/C++. The game is almost done and now, I want to create a map editor. The game contains numerous classes and their number will vary depending on the number of objects the map requires. I was thinking of creating a separate structure to hold level data and store it as a map. The problem is that the size v...

How do I read the contents of a small text file into a scalar in Perl?

I have a small text file that I'd like to read into a scalar variable exactly as it is in the file (preserving line separators and other whitespace). The equivalent in Python would be something like buffer = "" try: file = open("fileName", 'rU') try: buffer += file.read() finally: file.close() except IOErro...

File access denied, c# console application error.

This is a really odd security issue with a C# (3.0) Console application. The application creates a folder and copies a bunch of files into that folder, it then also generates some files and saves them into the same folder. File streams are always closed. The copied files are done using File.Copy. Once the files are there, I don't seem t...

Writing XML with C#

My C# is a bit rusty and I've never written XML with it before. I'm having trouble getting the XML to write to a file if I attempt to write anything other than elements. Here is the test code that I have: var guiPath = txtGuiPath.Text; MessageBox.Show("Dumping File: " + guiPath); try { var writer = new XmlTextWriter("client_setting...

Deleting a File using J2ME throws an IOException

I am attempting to delete a file using J2ME's FileConnection.delete() method, but I an IOException is being thrown each time I call the delete() method. I have written a conditional statement to verify the existence of the file, but irregardless of that fact, an IOException is thrown. According to the FileConnection API, when delete() i...

Best way to copy or move files with Objective-C?

I was wondering, is there a best practice to write an OSX programm that copies or moves a file from one place to another? is there some NSSomething method I can call? Do I have to work with Input/Output streams? Or is the best way maybe to just rely on passing commands to the finder? Bonus question: How do I get percentages a la "co...

What are the possible exception occurs during copying file?

Hi, My program has to copy file from one folder to another folder. I have used InputStream and OutputStream to do he same. The file size is about 5GB. what are all the possible exception may occur during this process and how?. As i need mention the same in unit testcase document...Please help. ...