I have many processes reading a file stored on a network share. Originally I was only able to have one process read the file, all the others would throw exceptions. I implemented the following code to deal with that:
using (StreamReader fileStreamReader = new StreamReader(File.Open(path, FileMode.Open, FileAccess.Read, FileShare.Read)))...
Code:
String tempFile = Path.GetTempFileName(), read = "";
TextReader pending = new StreamReader("c:\\pending.txt");
TextWriter temp = new StreamWriter(tempFile);
read = pending.ReadLine();
while ((read = pending.ReadLine()) != null)
{
temp.WriteLine(read);
}
...
Hi,
I am currently writing a plugin in C++. For my functionality I ask the API to save out a file. The API gives me a return value when the file is written... or so it seemd. The problem is, that this return value is returned too early so that I can not be sure, that the file is written completely.
Is there a possibility of checking t...
I want users to be able to upload their CV in PDF, .txt, .doc, .docx; and allow potential employers to download the file.
What data type should I use? In MS MSQL, I would use varbinary(max), right? But since I'm new to MySQL I'm a bit confused. :)
...
Hi,
I made simple python program to generate big text file:
import sys
import random
f = open('data.txt', 'w')
for i in range(100000000):
f.write(str(i) + "\t" + str(random.randint(0,1000)) + "\n")
f.close()
When I launch it using CPython it eat all available OS memory and write nothing to the file.
When I launch it on Jyth...
According to the POST method uploads section of the PHP Manual, $_FILES['userfile']['name'] is the original name of the file on the client machine. Example #2 in that section uses the basename function with $_FILES['userfile']['name'] like the following:
$uploaddir = '/var/www/uploads/';
$uploadfile = $uploaddir . basename($_FILES['user...
I'm trying to declare a long value in Java, which unfortunately does not work.
This is my code. It results in the following error message: "The literal 4294967296 of type int is out of range".
long bytes = 4294967296;
I need this value to make a file filter that filters out files that are bigger than 4294967296 bytes (4GB). The other...
I could use some advice.
I'm building a website in which the general user needs to be able to transfer files to the site administrator. It could be done one of two ways:
1] Some kind of web based interface - PHP perhaps - to send files to the FTP. I've done some Googling but have yet to come up with anything concrete that works. I'v...
How can I add files starting with dot (hidden files) in git repo? Git seems to always ignore those.
When I type "git add .", dotfiles in GIT_DIR are added, but not from subdirectories. On the other hand, "git add subdir/.dotfile" won't work.
I tried "git add -f" and putting "!.*" in GIT_DIR/.git/info/exclude. No luck.
...
I understand that file upload speeds are limited by the upload speed of the internet connection among other things. Is it possible to use jquery or some other method to compress the file locally before upload and then upload a file to the server? Any other solutions?
...
The company I work for is trying to switch a product that uses flat file format to a database format. We're handling pretty big files of data (ie: 25GB/file) and they get updated really quick. We need to run queries that randomly access the data, as well as in a contiguous way. I am trying to convince them of the advantages of using a da...
What is the best way to write to files in a large php application. Lets say there are lots of writes needed per second. How is the best way to go about this.
Could I just open the file and append the data. Or should i open, lock, write and unlock.
What will happen of the file is worked on and other data needs to be written. Will this ...
I'm writing a program that works with files.
I need to be able to input data as structures, and eventually read it out.
The problem i have at the moment is with this code:
typedef struct {
char* name;
.....
}employeeRecord;
employeeRecord record;
char name[50];
if(choice == 1)
{
/*Name*/
printf("\nEnter the...
#!usr/bin/perl
@array = ();
open(myfile,"sometext.txt");
while(<myfile>)
{
chomp;
push(@array,[split(" ")]);
}
close(myfile);
print @array[0];
Instead of printing the elements of the first array in this multidimensional array, it outputs the hexadecimal(?) pointer reference. If anyone knows how I can print this array, please po...
I am downloading files through IFRAME method described here:
http://encosia.com/2007/02/23/ajax-file-downloads-and-iframes/
And am showing progress in a div and hiding this div on load completion:
$(objIframe).load(function() {
$("#spinner").hide();
});
The trouble is, this callback function is never called in Internet Explorer ...
Example code:
my $ua = LWP::UserAgent->new;
my $response = $ua->get('http://example.com/file.zip');
if ($response->is_success) {
# get the filehandle for $response->content
# and process the data
}
else { die $response->status_line }
I need to open the content as a file without prior saving it to the disk. How would you do ...
When using SQL Server Express 2005's User Instance feature with a connection string like this:
<add name="Default" connectionString="Data Source=.\SQLExpress;
AttachDbFilename=C:\My App\Data\MyApp.mdf;
Initial Catalog=MyApp;
User Instance=True;
MultipleActiveResultSets=true;
Trusted_Connection=Yes;" />
We find that we can't ...
Hello, I'm trying to use a local c# app to pull some images off a website to files on my local machine. I'm using the code listed below. I've tried both ASCII encoding and UTF8 encoding but the final file is not an correct. Does anyone see what I'm doing wrong? The url is active and correct and show the image just fine when I put the...
I have a file with entries such as:
26 1
33 2
.
.
.
and another file with sentences in english
I have to write a script to print the 1st word in sentence number 26
and the 2nd word in sentence 33.
How do I do it?
...
If I try executing the following code
f = file('test','rb')
fout = file('test.out','wb')
for i in range(10):
a = f.read(1)
fout.write(a)
f.close()
f = fout
f.seek(4)
print f.read(4)
Where 'test' is any arbitrary file, I get:
Traceback (most recent call last):
File "testbad.py", line 12, in <module>
print f.read(4)
IO...