file-handling

Jython 2.2.1, howto move a file? shutils.move is non-existant!

'''use Jython''' import shutil print dir(shutil) There is no, shutil.move, how does one move a file with Jython? and while we at it, how does one delete a file with Jython? ...

How to rename a file name without change its type?

Hi to all, I have doubt in renaming java files... My application has to rename the incoming file which is mdb,dbf,xls,xml,etc. format. I used the following source code. eg: String filename = "D:/sample.mdb"; File filediriden = new File(filename); String[] filetype = filename.split("\\."); System.out.println("Filetype :"+filetype[1]); ...

Deleting non-empty directories in Java

Supposing I have a File f that represents a directory, then f.delete() will only delete the directory if it is empty. I've found a couple of examples online that use File.listFiles() or File.list() to get all the files in the directory and then recursively traverses the directory structure and delete all the files. However, since it's ...

How do I add a file browser inside my Java application?

I am new to Java progamming and am building a application that will add, display and remove files from a given folder location. I have added files using JFileChooser and know how to delete the files. However I am stuck with the display portion. I want to display the files and folder using different icon inside my application. I tried t...

How does one print external files (XLS, PDF, DOCX, etc) from ASP.NET?

We have an application in classic ASP that allows user to 'attach' files to information. These can be PDFs, spreadsheets, Word documents, etc. In the new ASP.NET version, one requested option was for a "Print All" (one user has a situation where there are 34 attached files and, in the current system, she has to open and print each one ...

How to read string literals and comments from a text file?

We are taking input from a text file. Every line is split in strings at white spaces, so we can further classify the elements. Making the string the problem is, that I also want to read string literals (e.g. "Thank you") as they are without splitting and comments too (both // and /* ....*/). Is there any way I can do this? ...

Can someone please tell me what is wrong with this code...?

Hi All, I have a section of code in a controller that replaces existing HTML with an IMG tag. The code is as follows: render :update do |page| page.replace_html "chart-div", "<img src=\"#{chart.chart_file}\"/>" #chart.chart_file is a path end For whatever reason, I keep receiving the following error: ActionController::Routi...

How to serve a MVC-view with image paths from directory?

I'm kind of new to the whole MVC concept, since I just recently started developing a web site using CakePHP framework. Therefore I turn to you asking for how to achieve the following in a best-practice-way. I want to be able to place a number of pictures in a directory, which then is scanned for all filenames in it. These filenames shou...

Unix: seeing file handles like with "lsof -l"

I did the commands (source): $ exec 3>/tmp/thirdfile $ exec 4>/tmp/fourthfile $ echo drib >&3 $ echo drab >&4 $ echo another drib >&3 $ echo another drab >&4 $ exec 3>&- $ exec 4>&- How can I see the file handles, something like with "lsof -l"? ...

copy file from one folder to other

I want to move all files from one folder to other. my code is following in this i made a folder in which i want to copy all file from templats folder $doit = str_replace (" ", "", $slt['user_compeny_name']); mkdir("$doit"); $source="templat/"; $target=$doit."/"; $dir =...

Delineating a Read File

Not really too sure how to word this question, therefore if you don't particularly understand it then I can try again. I have a file called example.txt and I'd like to import this into my Python program. Here I will do some calculations with what it contains and other things that are irrelevant. Instead of me importing this file, goin...

Function to read files one by one in a directory

I am implementing an SMTP-sender in C which is supposed to read a file from a directory whenever it is created, process data and delete the file. How can I implement this polling function which should keep doing this automatically? ...

File Rename problem?

I'm using VB6 and I have a folder where I have n number of files. I want to change the file extension to .txt. I used the code below to change the extension of all .fin files to .txt. Dim filename1 As String filename1 = Dir$(txtsourcedatabasefile & "\*.fin", vbDirectory) Do While filename1 <> "" Dim strInput As String Dim strO...

insert text inside a line

I have a file pointer which I am using with fgets() to give me a complete line along with the new line in the buffer. I want to replace 1 char and add another character before the new line. Is that possible? For example: buffer is "12345;\n" output buffer is "12345xy\n" This is the code: buff = fgets((char *)newbuff, IO_BufferSize...

Why is this program not showing the first line again and again?

#include <stdio.h> #include <stdlib.h> #include <string.h> char *readLine(FILE *inFile) //Simply reads line in a text file till "\n" { char *line = realloc(NULL, 1); char c; int i=0; while (!feof(inFile)) { c = fgetc(inFile); if (ferror(inFile)) printf("Error reading"); if (c == 10) ...

Perl: opening a file, and saving it under a different name after editing.

Hello! I'm trying to write a configuration script. For each customer, it will ask for variables, and then write several text files. But each text file needs to be used more than once, so it can't overwrite them. I'd prefer it read from each file, made the changes, and then saved them to $name.originalname. Is this possible? ...

Parsing CSV files in C#

Is there a default/official/recommended way to parse CSV files in C#? I don't want to roll my own parser. Also, I've seen instances of people using ODBC/OLE DB to read CSV via the Text driver, and a lot of people discourage this due to its "drawbacks." What are these drawbacks? Ideally, I'm looking for a way through which I can read th...

read lastaccess time for media files

Hie i am kind of stuck here see, i am designing a service app that searches files and checks their lastaccesstime to determine which files(mp3 or such) have been played recently. While testing the behavior of windows on this i noticed the update only happens when openning a folder containing the file and never again. ...

Why am i getting this warning in "if (fd=fopen(fileName,"r") == NULL)"?

FILE *fd; if (fd=fopen(fileName,"r") == NULL) { printf("File failed to open"); exit(1); } This is a code snippet. When I compile it with gcc, i get the following warning:- warning: assignment makes pointer from integer without a cast When I put fd=fopen(argv[2],"r") within brackets, the problem gets solved.. I am not abl...

C: The remove function removes all files?

I am using something like this: char *file; file = (char *)malloc(BUFSIZE * sizeof(char)); printf("Enter the filename:"); scanf("%s", file); if(remove(file)) { printf("Error while removing"); } I created two files: touch filetobedeleted1.txt chmod 777 filetobedeleted1.txt touch filetobedeleted2.txt chmod 444 filetobedeleted2.txt ...