file

Modify a .txt file in Java

I have a text file that I want to edit using Java. It has many thousands of lines. I basically want to iterate through the lines and change/edit/delete some text. This will need to happen quite often. From the solutions I saw on other sites, the general approach seems to be: Open the existing file using a BufferedReader Read each l...

What is the best way to generate a unique and short file name in Java.

I don't necessarily want to use UUIDs since they are fairly long. The file just needs to be unique within its directory. One thought which comes to mind is to use File.createTempFile(String prefix, String suffix), but that seems wrong because the file is not temporary. The case of two files created in the same millisecond needs to be ...

Simple PHP form: Attachment to email (code golf)

Imagine a user that would like to put a form on their website that would allow a website visitor to upload a file and a simple message, which will immediately be emailed (ie, the file is not stored on the server, or if it is then only temporarily) as a file attachment with the note in the message body. What is the simplest way to accomp...

Python: Mixing files and loops

I'm writing a script that logs errors from another program and restarts the program where it left off when it encounters an error. For whatever reasons, the developers of this program didn't feel it necessary to put this functionality into their program by default. Anyways, the program takes an input file, parses it, and creates an outp...

Deferring BufferedWriter.write to another thread

I have an event processing scheme which should also eventually write to file; I cannot afford to delay the event when the file is being flushed, i.e. waiting to the end of BufferedWriter.write(String). I'm looking for the easiest way to achieve that (is there's a library doing that? I reckon that I'm not the only one who had this proble...

Haskell: Writing text files and parsing them back to original format

Hi - I have a list of tuples of format [(String,String)] and I need a function to write the contents of the list to a text file, then another function to read this text file in as the same list of tuples. Here's what I've got for the saving function: save :: Table -> IO() save [] = writeFile "database.txt" "" save zs = do { writeFile "d...

How to check if a file exists on a server using c# and the WebClient class

In my application I use the WebClient class to download files from a Webserver by simply calling the DownloadFile method. Now I need to check whether a certain file exists prior to downloading it (or in case I just want to make sure that it exists). I've got two questions with that: What is the best way to check whether a file exists o...

How to write out an email with mutt, grep the file, then execute a command at new email

I am trying to write a series of scripts that will execute other scripts on my server depending upon text from an email that was just received. I am using mutt as a text based email client, but have no idea where to start for this. I am hoping to understand how this works more than just solving the problem, because this project of mine...

How to start the associated program when selecting more than one files?

I have set .jpg file associated to my own program. I want to add the context menu to .jpg files, so I set the entry of HKCR.jpg\shell\open\command to "myProg.exe %1". After associating, there will be an item on the top of the context menu saying "Open image with myprog". This works right when I select a single .jpg file, but when I selec...

Storing file structure in PHP

What is the best way to store a file structure, along with files, say from a Zip file? Currently each file is a row in the MySQL database, but obviously no structure can be read from that. I want to avoid storing a binary file. All files should be plain text. Each zip/file structure is private to the user whom submitted it. ...

How do I generate and send a .zip file to a user in C# ASP.NET?

I need to construct and send a zip to a user. I've seen examples doing one or the other, but not both, and am curious if there are any 'best practices' or anything. Sorry for the confusion. I'm going to generating the zip on the fly for the web user, and sending it to them in the HTTP response. Not in an email. Mark ...

Moniter folder permission

Anyone know how can we moniter file /folder permission on windows. Suppose a user can change the folder permission, the application can log the user, timing and other details. If neone know third party tool/script for the same, plz suggest. -Thanks ...

ASP.NET MVC and AjaxFileUpload

Ok, this is driving me nuts. I have been trying to figure this out forever now. I want to to perform an async upload using ajaxFileUpload. I have it posting the file to my controller just fine, however, when i try to return a JsonResult from it, I get a "Save File As" dialog box. I have tried everything to get around this and i either ge...

How to include PHP file in SHTML pages?

I have a shtml file index.shtml in which I want to include a PHP file which performs some programing and returns HTML data. I am trying to include my PHP file but I don't know how to do that, I tried following but nothing is working, Following line is just printing an error, "[an error occurred while processing this directive] ": <!--...

Open file by its full path in C++

Hello, I want the user to give me the full path where the file exists and not just the file name. How do I open the file this way? Is it something like this: ifstream file; file.open("C:/Demo.txt", ios::in); Because it doesnt seem to work..I think.. Thanks in advance, Greg ...

Forms application "Not Responding" when copying large files?

Hey Folks, I've got a file organizer application I'm working on. The files are regularly 500MB to 2GB. Everything works fine, but it is extremely annoying that the application "Stops Responding." What I'd like to do is a byte by byte or meg by meg copy with some Application.DoEvents() in there after each read/write action. Something...

Encode wav file to pcm

Hello everybody, I need to encode a wav file to another file format (pcm). This format has to following properties: 8kHz, 16-bit. Has anybody an idea how to do this in c# or vb? Thank you in advance, JaQ ...

How do I upload pickled data to django FileField?

I would like to store large dataset generated in Python in a Django model. My idea was to pickle the data to a string and upload it to FileField of my model. My django model is: #models.py from django.db import models class Data(models.Model): label = models.CharField(max_length=30) file = models.FileField(upload_to="data") I...

Running console application from C# but application can't create file

i have windows forms application wich runs another console application here is the part of code prog = new Process(); prog.StartInfo.FileName = exefile; the console application should create file but when running that application from C# it doesn't creates any file when im running console application with double click it works fine he...

Atomic modification of files across multiple networks

I have an application that is modifying 5 identical xml files, each located on a different network share. I am aware that this is needlessly redundant, but "it must be so." Every time this application runs, exactly one element (no more, no less) will be added/removed/modified. Initially, the application opens each xml file, adds/remov...