file-io

Can I write to the end of a 5GB file in Java?

Can I write to the end of a 5GB file in Java? This question came up in my office and no one is sure what the answer is. ...

.Net FileIOPermission & ApplicationData

I'm getting a FileIOPermssion exception thrown when trying to create a folder in Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) on some computers. I've established that there is some form of antivirus running on the computer in question, but I haven't been able to get in contact with their IT department to find out ...

How do you clear output buffers when the program forks?

I have a program that writes to a FILE *cgiOut and just after it has written to the stream, I need to fork and run a background process. The trouble is that after the fork, the FILE * stream seems to flush out sometimes and I get duplicated output (after the fork, all open files are closed which I guess causes the buffers to be flushed)...

How do I find out how many files are in a directory?

I need to get a count of the number of files in a directory. I could get the names of all the files in the directory using System.IO.Directory.GetFiles() and take the length of that array but that takes too long on large directories. Is there a way to get just the count without having to get the names? ...

Spring Integration 1.0 RC2: Streaming file content?

I've been trying to find information on this, but due to the immaturity of the Spring Integration framework I haven't had much luck. Here is my desired work flow: New files are placed in an 'Incoming' directory Files are picked up using a file:inbound-channel-adapter The file content is streamed, N lines at a time, to a 'Stage 1' chan...

C# DriveInfo FileInfo

This may seem like a stupid question, so here goes: Other than parsing the string of FileInfo.FullPath for the drive letter to then use DriveInfo("c") etc to see if there is enough space to write this file. Is there a way to get the drive letter from FileInfo? ...

Unittesting methods that contain Filesystem calls

I have a method I want to unittest that has filesystem calls in it and am wondering how to go about it. I have looked at http://stackoverflow.com/questions/129036/unit-testing-code-with-a-file-system-dependency but it does not answer my question. The method I am testing looks something like this (c#) public void Process(string input) {...

can you get XmlCompiledTransform progress?

Hello, I want to read an xml file, apply a transform, then write to another file. The best way I can think of is this: using (XmlTextReader reader = new XmlTextReader(new FileStream(_source, FileMode.Open))) using (XmlTextWriter writer = new XmlTextWriter(new StreamWriter(_destination))) { _xslTransform.Transform(reader, writer); } ...

How do you test a file.read() error in Python?

I have the following code (adapted from an example given in Dive Into Python) that reads the entire contents of a file into a buffer. buffer = "" try: file = open(postFileName, 'rU') try: # Read the entire POST log file into a buffer buffer += file.read() finally: file.close() except IOError: buf...

Moving files on different volumes in .NET

Hi, Apparently I can't move files on different volumes using Directory.Move. I have read that I have to copy each file individually to the destination, then delete the source directory. Do I have any other option? ...

Whats the deal with boost.asio and file i/o?

I've noticed that boost.asio has a lot of examples involving sockets, serial ports, and all sorts of non-file examples. Google hasn't really turned up a lot for me that mentions if asio is a good or valid approach for doing asynchronous file i/o. I've got gobs of data i'd like to write to disk asynchronously. This can be done with nativ...

Can I force windows to challenge a user for authentication?

Here is the scenario: There is a file on the network I'd like my program to have access to. They haven't authenticated on the network when they run my software, so accessing the file fails. If I have the user open up explorer and manually navigate to the network path, they get asked by windows for their credentials, and from then on, w...

Get specific lines from a text file

I am working on a UNIX box, and trying to run an application, which gives some debug logs to the standard output. I have redirected this output to a log file, but now wish to get the lines where the error is being shown. My problem here is that a simple cat output.log | grep FAIL does not help out. As this shows only the lines which ...

reading and writing files ...

Hi guys as a homework i have to write a program that read from a file that contain the folowing: toto, M, 50 fifi, F, 60 soso, F, 70 lolo, M, 60 fifi, F, 60 and then find the following: Which mark is most repeated and how many times is it repeated avgerage all students avgerage all male avgerage all female how many are below ...

Max File Extension Length

Is there a maximum lengh for a file extension? The longest one I've seen is .compiled (8 chars) Useless Background I'm creating a IHttpHandler to return image icons for a specific filename. I'm simply calling a FileImage.axd?ext=pptx. I'm generating the files on the fly using SHGetFileInfo similar to my post for WPF, then caching th...

System.IO.Directory.GetFiles returns different result than Windows XP Search Companion

Hi, I am using this statement to find all files recursively: fileNames = System.IO.Directory.GetFiles(path, "*.*", System.IO.SearchOption.AllDirectories); The total number of files that are found is sgnificantly lower than wehen using Windows XP Search Companion. This is not caused by hidden files, I checked that. It looks like s...

How does relative file path works in Eclipse.

So my 2009 new years resolution is to learn Java. I recently acquired "Java for Dummies" and have been following along with the demo code in the book by re-writing it using Eclipse. Anyway, every example in the book that uses a relative path does not seem to read the .txt file it's supposed to read from. Here is the sample code: impo...

What is the best(least impacting?) method to read a file that is being written by another process?

I'm looking for the least impacting method to read a few different log files. By "least impacting" I mean the read wont affect log rotation, wont cause undue I/O activity, etc. I'm looking to accomplish this with Java... Google afforded me the following little snippit of code: FileStream fs = new FileStream("C:\foo.txt", FileMode.Ope...

What's the best way to synchronize XmlWriter access to a file to prevent IOExceptions?

There are multiple places in an application which call XmlWriter.Create on the same file, all accessed through the following function. When one calls while another is still writing, I get an IOException. What's the best way to lock or synchronize access? Here's the function that's being used: public void SaveToDisk() { ...

Want to read a file to a TStringList

Hi! Yes I want to read a simple a logfile into a TStringList and that is easy done with LoadFromFile. But the problem is that the file can be already opened by another program at the same time so an exception may appear. I have tried to use: FileMode := fmShareCompat; But it won't work. I have also tried to use: fFilePath := fPathL...