file-io

Is it possible to add custom metadata to file

I know that each file has metadata like title, subject, keywords and comments: http://my.jetscreenshot.com/2777/20100713-vu9m-31kb.jpg but what if i need custom metadata like tags for example is it possible to do it with C#? ...

storing the output of a cursor object in csv format

i've accessed a database and have the result in a cursor object. but i couldn't save it :( cur_deviceauth.execute('select * from device_auth') for row in cur_deviceauth: print row writer = csv.writer(open("out.csv", "w")) writer.writerows(cur_deviceauth) i don't get an error msg and i couldn't write it. how do i make it?...

PHP: endless loop of reading folders?

hey guys, i wonder how i can solve the following problem: I'm reading a folder on my server and i'm displaying the contents as follows. if there's an image i'll print an image, if there's folder i'll print a div with a folder icon. i wonder if it's possible click on one of those subfolders and then display the contents of this folder th...

Is Parallel File.Read Faster than Sequential Read?

I just wonder is parallel File.Read using PLINQ/Parallel can be faster? My code is as follows ( .Net 4.0): public static void ReadFileParallel(List<string> fileName) { Parallel.Foreach(fileName, file=>File.Read(file)); } public static void ReadFilePLINQ(List<string> fileName) { fileName.AsParallel().foreach(file=>File.Read(file)...

Retrive and parse an XML from the web

I want to use XPath (in Java) to parse XML files. However these XML files are only available on the web (downloading them all manually is not an option (of course they have to be "downloaded" in order to be processed). So basically my question is how to do I take a URI object and convert it into a File object. Do I need to use SCP or so...

Read structured data from binary file - ?

I know the file structure, suppose this structure is this: [3-bytes long int],[1-byte long unsigned integer],[4-bytes long unsigned integer] So the file contains chains of such records. What is the most elegent way to parse such a file in Java? Supposedly, we can define a byte[] array of overall length and read it with InputStream, ...

Overloading operator<< to work for string

Hi! In the following code: using namespace std; //ostream& operator<< (ostream& out,const string & str) //{ // out << str.c_str(); // return out; //} int _tmain(int argc, _TCHAR* argv[]) { ofstream file("file.out"); vector<string> test(2); test[0] = "str1"; test[1] = "str2"; ostream_...

Handling File Contents Before Writing to Disc C#

So I have decrypted a file and am left with a byte array containing this (Uni-encoded): Content-Type: text/plain; name="testfile.txt" Content-Transfer-Encoding: binary Content-Disposition: attachment; filename="testfile.txt" My super secret message. Where "My super secret message." is the contents of the file, which could be ...

Reading bytes into a structure in C#

Hello again, time for another off the wall question. I am writing an MD2 loader for my small 3D engine project. In my old language (C) I could define a structure and then read() from an open file directly into the structure. I have a structure to hold the header information from the MD2 file, as follows: [StructLayout(LayoutKind.Sequent...

How to access local files on server in JBoss application?

I am looking to access all files in a local directory in a JBoss application. I can put the directory anywhere in my war including WEB-INF if necessary. I then want to access each file in the directory sequentially. In a normal application if the directory was in the run location I could do something like: File f = new File("myDir"); if...

How to reload a file in python?

If I have a script that writes 1000 lines to file and then continues regular expressions against that file, however only the last 100 lines of text written will be available. One way around this is to close and reopen the file. Is there a way to reload a file after being written to or should I just make a write close open module? It may ...

How do I insert data into a pre-allocated CSV?

Text file (or CSV) is: Data:,,,,,\n (but with 100 ","s) In C or C++ I would like to open the file and then fill in values between the ",". i.e.- Data:,1,2,3,4,\n I'm guessing that I need some sort of search to find the next comma, insert data, find the next comma insert, etc. I was looking at memchr() for a buffer and...

How to Delete a entire folder and all its contents including readonly files

i currently use this code to delete a folder and its contents: string tempFolder = System.Environment.GetEnvironmentVariable("HomeDrive"); System.IO.Directory.Delete(tempFolder + "\\" + "Test", true); and it works GREAT but, it will delete the folder and its contents but, will NOT delete read only files. So how using c# targeted Frame...

How can I check if a file is empty or not? and empty it before writing if not?

myfile = open('out.txt', 'a') myfile.write(caption) I write something like this whenever my script is run. But after the first run, it keeps on adding same data to the file. How can I check if it's empty or not and tell it to write only if it's empty? ...

What is the best way to write the contents of a StringIO to a file?

What is the best way to write the contents of a StringIO buf to a file ? I currently do something like: buf = StringIO() fd = open ('file.xml', 'w') # populate buf fd.write (buf.getvalue ()) But then all of buf would be loaded in memory at the same time.. ? ...

Write a File in Phone Memory using J2ME

Hello All... I have just downloaded the Samsung SDK 1.2 for Java Development. Now, it's pure based J2ME architecture, so I have a requirement to store some files inside the memory for my application usage. That file can have a .csv extension, so for that I have tried JSR 75's FileConnection class with following piece of code : try { ...

Difference between binary and text I/O in python on Windows

I know that I should open a binary file using "rb" instead of "r" because Windows behaves differently for binary and non-binary files. But I don't understand what exactly happens if I open a file the wrong way and why this distinction is even necessary. Other operating systems seem to do fine by treating both kinds of files the same. ...

problem with casting float -> double in C when fread

I have a problem with casting from float to double when fread; fread(doublePointer,sizeofFloat,500,f); if i change double pointer to float pointer, it works just fine. However,i need it to be double pointer for laster on, and i thought when i write from small data type (float)to bigger data type(double)'s memory, it should be fine. ...

What Time datatype should I use

This seems to be a silly question but, I have to read some data from a text file this data is ID Time Value Graph1 0:00 1.0 Graph1 0:30 1.5 Graph1 1:00 2.0 or ID Time Value Graph1 0.00 1.0 Graph1 0.50 1.5 Graph1 1.00 ...

Problem with UTF-8 String and binary data

prehistory: http://stackoverflow.com/questions/3262013/java-regular-expression-for-binary-string I can extract a substring with binary data I need, but when I use String s = matcher.group(1); It seems that data is spoiled, to be exact spoiled are only those chars that belong to extended ASCII table, probably from 128 to 255. Othe...