file-io

strange file reading problem in c++: fread()

I have a very strange problem when reading a binary file. void metaDataProcess(FILE *f){ unsigned __int32 obLength; unsigned __int32 numProp; char* objPath; unsigned __int32 rawDataIndex; int level; fread(&obLength,sizeof(obLength),1,f); objPath=new char[obLength]; cout<<"i am at"<<ftell(f)<<endl; fr...

Get folder size

Do you know how can I get the folder size in Java? The length() method in the File class only works for files, using that method I always get a size of 0. ...

How can I read from and write to a local directory from any self-hosted Wordpress blog page using PHP?

I want to read and write text files to /data/filename.txt using php. This functionality works fine on the main page, but if I click the Previous Entries button (which switches to page 2), the php script does not seem to be present (as the Flash files are unable to access it). ...

Does a file read from a Java application invoke a system call?

My understanding is that a user application requesting a file system path (eg. /aFile) will invoke the File System and get back the virtual address of the requested file. Then the application will attempt a read/write operation with that address as argument, that as a CPU instruction? On execution of the read command the Memory Managemen...

Procedure to open, write and append in Ada

This question is a follow-up of the post at http://stackoverflow.com/questions/3171332/ada-file-operation-instantiation-and-exception about writing to files in Ada. I chose to place this question in a separate post so that it'll become visible to more people as I already accepted an answer on a slightly different issue (which was on ...

Deleting parts of a data file in java

I have a file which I write some java objects. After writing, sometimes I need to delete some of these objects placed at ramndom positions in the file. Is there a way to delete a selected object from the file without replacing the whole file? Thank you. ...

file reading: feof() for binary files

Hey; I am reading a binary file. and when it reaches the end. it seems it is terminated by feof() function. is it because there is no EOF character for binary files? if so how can i solve it. currently my code is using a while loop while (!feof(f)) when it reaches the end of file at position 5526900. it doesn't stop. it just keeps...

reading file data mixing strings and numbers in python

I would like to read different files in one directory with the following structure: # Mj = 1.60 ff = 7580.6 gg = 0.8325 I would like to read the numbers from each file and associate every one to a vector. If we assume I have 3 files, I will have 3 components for vector Mj, ... How can I do it in Python? Thanks for y...

Create file with DeleteAfterOpen, and allow other process to read the file

Is it possible to create a file using the FileStream object in .net, specifying DeleteAfterClose option and allow read access to that file? I've tried using: System.IO.FileStream strBMP = new System.IO.FileStream(sFileName, System.IO.FileMode.Create, System.Security.AccessControl.FileSystemRights., System.IO.FileShare.ReadWrite, 1024, ...

java.io.StreamCorruptedException: invalid type code: AC

I am trying to read some objects from a file. The code works fine for the first iteration and at the second iteration it gives a StreamCorruptedException. Here is my code, private ArrayList<Cheque> cheques = null; ObjectInputStream ois = null; try { cheques = new ArrayList<Cheque>(4); ois = new ObjectInpu...

Difficulties to send File to view using FileContentResult action method.

Hello, I need to display in image on the view this way <img src = <% = Url.Action("GetImage", "Home", new { productID })%> This is the action which's supposed to supply data public FileContentResult GetImage(int ID) { var img = db.Images.Where(p => p.ID == ID).First(); return File(img.ImageData, img.ImageMimeType); } This exam...

[C] fread/ftell apparently broken under Windows, works fine under Linux

So here's the problem, I'm reading a level file for my game, works fine under linux: @0 @12 200x200 version 3 @16 973 blocks @989 @993 18 zones But under windows I get the following result: @0 @212 200x200 version 3 @216 973 blocks @1200 @1204 18 zones Uh? The windows ftell stats with an offset of 200? Reading the file apparently y...

Redirecting ostream to file not working

I have a custom logging system which allows me to send information to a log file and the console depending on the verbosity currently selected. Right now, the trouble I am having is with the output to the file, with output to the console working fine. Here is an example: ilra_talk << "Local IP: " << systemIP() << " | Hostname: "...

reading primitives from file in C

Hi Folks, I am new to C, and want to read some data from a file. Actually, I find many reading functions, fgetc, fgets, etc.. But I don't know which one/combination is the best to read a file with the following format: 0 1500 100.50 1 200 9 2 150 10 I just need to save each row above into a struct with three data members. I...

Java file i/o throughput decline

I have a program in which each thread reads in files many lines at a time from a file, processes the lines, and writes the lines out to a different file. Four threads split the list of files to process among them. I'm having strange performance issues across two cases: Four files with 50,000 lines each Throughput starts at 700 lines...

Listing And Linking Files

I'm developing a Servlet that should act listing all the files that are on the directory C:\UploadedFiles\CompanyWork on the page and put the link for the files on each one, like this example(using Test.doc as test): <a href="C:\UploadedFiles\CompanyWork\Test.doc">Test.doc</a> But I don't know how to do this, I only know how to get th...

how do i store the output of my cursor object to a text file?

I have accessed a database and have the result in a cursor object. when I try to save it to a text file, python says TypeError: argument 1 must be string or read-only character buffer, not sqlite3.Cursor can someone tell me what I should do here? curobject.execute('select * from device_auth') for row in curobject: print ...

How do you check the success of open (file) in Perl?

Hello, The following (not very Perl-ish) code #!/usr/bin/perl if (! -e "mydir/") { print "directory doesn't exist.\n"; } open (my $fh, ">", "mydir/file.txt"); if ($fh) { print "file opened.\n"; print $fh; print $fh "some text\n" or die "failed to write to file.\n"; close ($fh); } else { print "failed to open file.\n"; } ...

Reading a text file with fixed length fields and records in Delphi

I need to read data from a text file where the field lengths and record lengths are fixed. Fields are either zero padded or space padded, always appear in the same order and each record is terminated by a CRLF. The file can have one of three possible record types determined by the first character in the record. So far I've create a base...

Setting the root folder to index

I have this code here: import java.io.*; import javax.servlet.*; import javax.servlet.http.*; /** * * @author Nathan Campos */ public class Files extends HttpServlet { PrintWriter out = null; // moved outside doGet() for use in ls() @Override public void doGet(HttpServletRequest request, ...