file-io

Enter File Name When Executing Program In C++

Hello, I'm learning C++, then i was searching for some codes for learn something in the area that i love: File I/O, but i want to know how i can tweak my code for the user type the file that he wants to see, like in wget, but with my program like this: C:\> FileSize test.txt The code of my program is here: // obtaining file size #in...

Put A String In A ifstream Method

Hello, I'm learning C++ and i'm getting some troubles when i'm trying to use a String in a ifstream method, like this: string filename; cout << "Enter the name of the file: "; cin >> filename; ifstream file ( filename ); Here is the full code: // obtaining file size #include <iostream> #include <fstream> using namespace std; int...

How to save a base64 string as an image using ruby

I'm integrating my Ruby on Rails app with a usps shipping system. Once you make a postage request, you pay for that postage and it's nonrefundable. Postage requests will return you an xml response including a base64 string, which is the shipping label. I'm able to render the shipping label in a view, however to make it foolproof, I w...

Reading .docx in C++

I'm trying to create a program that reads a .docx file and posts it content to a blog/forum for personal use. I finally have figured out how to use libcurl to do (what I figured) was the harder part of the program. Now I just have to read the .docx file, but have come under a snag. I can't seem to find any documentation on how to do t...

Fit algorithm does not accept my data

Hi! I'm using the algorithm described here to fit Gaussian bell curves to my data. If I generate my data array with: x=linspace(1.,100.,100) data= 17*exp(-((x-10)/3)**2) everything works fine. But if I read the data from a text file using file = open("d:\\test7.txt") arr=[] data=[] def column(matrix,i): return [row[i] for ro...

Is there an easy way to add (#) to a filename when you find a duplicate filename?

I'm outputting files in C# and want to handle files being saved with the same name by adding brackets and a number: FooBar.xml FooBar(1).xml FooBar(2).xml ... FooBar(N).xml Is there a simple way to do that in .NET? And is there a special name for the (#) construct? ...

Python file read problem

file_read = open("/var/www/rajaneesh/file/_config.php", "r") contents = file_read.read() print contents file_read.close() The output is empty, but in that file all contents are there. Please help me how to do read and replace a string in __conifg.php. ...

Reading part of a file in C using fread() and fseek()

I'm trying to read a file into a buffer in blocks of size BLOCK_SIZE (currently equal to 1000 unsigned chars). My code first finds the number of blocks it will have to read in order to read the entire file (usually 2-4), then iterates through a for loop reading the file (ignore the "+17+filenamesize" stuff, that is all needed for later i...

Problem with iterating over a lots of images in OpenCv with mac os

I'm trying to iterator over some directories containing approximately 3000 images. I load the image. If the image is loaded I release it. That is the smallest program that I can write to reproduce the error. After loading and releasing 124 images the program stops loading images. I think this a memory issue but I don't understand what...

Are include()s faster or database queries?

A client is insisting that we store some vital and complex configuration data as php arrays while I want it to be stored in the database. He brought up the issue of efficiency/optimization, saying that file i/o will be much faster than database queries. I'm pretty sure I heard somewhere that file includes are actually slow in PHP. Any s...

link to files displayed in output (ctrl + click)

Hello: I have a utility command that writes out a list of the 3 or so files it created, ie: Console.WriteLine("\t{0} \tUpdated @ {1}", file, lastWriteTime); The main reason I do this is so I can find the files easily after the routine runs (the location may vary). Ideally, I'd be able to hotlink and open the file using ctrl + click,...

kernelHow to read/write files within kernel module?

I know all the discussions about why one should not read/write files from kernel, instead how to use /proc or netlink to do that. I want to read/write anyway. I have also read http://www.linuxjournal.com/article/8110 However, problem is 2.6.30 does not export sys_read(). Rather its wrapped in SYSCALL_DEFINE3. So if I use that in my mod...

Win32: Monitoring for files being created or changed

1) How can I use FindFirstChangeNotification / FindNextChangeNotification + ReadDirectoryChanges to detect certain files being created or removed? 2) Is the FILE_NOTIFY_CHANGE_LAST_WRITE a reliable indicator of a file change? Application: I have an explicit list of files that may be located in different folders. Display contents depe...

Locks on Files Preventing Overwriting Files in ASP.NET

I have a small C# ASP.NET web application which generates several PNG image files from dynamically created .NET Chart controls. These are then used to: Create a lightbox effect Create a PDF Create a Zip file The application gets little usage and the data is updated often, so I'm re-creating everything on each load. The problem is, ...

Most efficient way to add attribute to begining of massive XML file in Java?

What is the fastest way to add an attribute to the root element of a massive XML file? These files are too large to be read into memory and I'd like to avoid as much of an I/O penalty as possible. ...

Is there a method in Objective-C to recursively create directories from a string?

I am trying to write to the iPhone app's cache folder with images downloaded from a server. My plan is to save the images in "site.com/path/to/image.jpg", since mirroring the server folder structure like that makes duplicate names impossible, and it just seems the right way to do it. Unfortunately, it seems I have to create the folders m...

Quicker (quickest?) way to get number of files in a directory with over 200,000 files

I have some directories containing test data, typically over 200,000 small (~4k) files per directory. I am using the following C# code to get the number of files in a directory: int fileCount = System.IO.Directory.GetFiles(@"C:\SomeDirectory").Length; This is very, very slow however - are there any alternatives that I can use? Edit ...

Load non-uniform data from a txt file into a msql database

I have text files with a lot of uniform rows that I'd like to load into a mysql database, but the files are not completely uniform. There are several rows at the beginning for some miscellaneous information, and there are timestamps about every 6 lines. "LOAD DATA INFILE" doesn't seem like the answer here because of my file format. It d...

Most efficient way to jump through a file and read lines?

I want to use a FileStream and seek from the beginning of the file while moving forward in the file .01% of the file size at a time. So I want to seek to a position in the file, read the entire line, if it matches my criteria I am done. If not, I seek ahead another .01. C# is OK but VB.NET preferred. I used to do it something like thi...

Many small files or one big file? (Or, Overhead of opening and closing file handles) (C++)

I have created an application that does the following: Make some calculations, write calculated data to a file - repeat for 500,000 times (over all, write 500,000 files one after the other) - repeat 2 more times (over all, 1.5 mil files were written). Read data from a file, make some intense calculations with the data from the file - r...