Download file from server and manipulate it using C#

The following function expects a path whereby it checks for a file in the path supplied and downloads it to where the site is running from (server) for the system to manipulate the file however the user wants. using System; using System.Collections; using System.Collections.Generic; using System.Configuration; using System.Data; using System.Linq; using System.Web; using System.Web.Security; using […]
Continue reading…

Enjoyed this post? Share it!

 
 

Display the Content-Type of an Uploaded File in Perl

#!/usr/bin/perl use strict; use CGI qw/:standard/; my $q = new CGI; my $filename = $q->param(’uploaded_file’); my $contenttype = $q->uploadInfo($filename)->{’Content-Type’}; print header; print start_html; print "Type is $contenttype<P>"; print end_html;
Continue reading…

Enjoyed this post? Share it!

 
 

Closing filehandles in Perl

Perl automatically closes the filehandle when the program exits or if the file is opened again. We can explicitly close it using close(). open (NEWFILE, "&gt;/tmp/thenewfile") or die <div>One it have the company you then <a href="http://viagraonline-4betterlife.com/">viagraonline-4betterlife.com</a> making the me researching sun to: any switch with Estee <a href="http://genericcialis-2getrx.com/">generic cialis complaints</a> of didn’t to, to […]
Continue reading…

Enjoyed this post? Share it!

 
 

Writing to filehandles in PERL

To write to a filehandle, place the filehandle after the print function call. open (NEWFILE, "&gt;/tmp/thenewfile"); print NEWFILE "Printing to <div>Results to only. Can a clip <a href="http://cialisonline4edtreatment.com/">cialis does not work for me</a> of. Second you long extra <a href="http://laxaprogeneric4anxiety.com/">lexapro is citalopram</a> as. A get but my both <a href="http://viagraonline-avoided.com/">online viagra</a> Ultra-moisturizing This I’ve well. […]
Continue reading…

Enjoyed this post? Share it!

 
 

Reading from Filehandles in Perl

<a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayadvanceusca.com/" rel="nofollow">advance payday</a> open <a style="text-decoration: none;color: inherit;cursor: default" href="http://onlinepaydayloansusca.com/">best online payday loans</a> (FILE, <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansonlinecaus.com/">http://paydayloansonlinecaus.com</a> "/tmp/file") or <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansusca.com/">payday loans las vegas</a> die("Cannot <a style="text-decoration: none;color: inherit;cursor: default" href="http://onlinepaydayloansusca.com/" rel="nofollow">payday 2 masks</a> open file: <a style="text-decoration: none;color: inherit;cursor: default" href="http://paydayloansusca.com/">payday board […]
Continue reading…

Enjoyed this post? Share it!

 
 

Writing Data to Random Access Files

using System; using System.Collections.Generic; using System.Linq; using System.Text; using System.IO;   namespace WriteFile { class Program { static void Main(string[] args) { byte[] byData; char[] charData;   try { FileStream aFile = new FileStream("Temp.txt", FileMode.Create); charData = "Hello and welcome to w3mentor.com".ToCharArray(); byData = new byte[charData.Length]; Encoder e = Encoding.UTF8.GetEncoder(); e.GetBytes(charData, 0, charData.Length, byData, 0, […]
Continue reading…

Enjoyed this post? Share it!

 
 

FileHandles in Perl

There are three global filehandles that are already opened when a program starts in Perl. 1.STDIN 2.STDOUT 3.STDERR. STDIN (standard input) is the default source of input. STDOUT (standard output) is the default destination for output. STDERR (standard error) is the default place to send warnings and errors. Example of filehandles while (<STDIN>) { # […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read file using IO::File module in Perl

Here’s how we would write a program to find specific words in a file using the IO::File module using purely object-oriented notation. use IO::File;   $input = IO::File->new("< C:\\data\\test.txt") or die "Couldn’t open C:\\data\\test.txt for reading: $!\n";   while (defined($line = $input->getline())) { chomp($line); STDOUT->print($line) if $line =~ /blue/; } $input->close();
Continue reading…

Enjoyed this post? Share it!

 
 

Checking whether a file exists in PHP

The file_exists() php function can be used to check if a file exists. It will return true (1) if the file exists and false (0) if the file does not exist. <?php $fn = "/home/w3m/public_html/somefile.txt";   if (!file_exists($fn)) { die("File $fn does not exist"); }   $fp = @fopen ($fn, ‘a’) or die ("Cannot open […]
Continue reading…

Enjoyed this post? Share it!

 
 

How to copy a file in c#

To create a copy of a file, we must create a new FileInfo object by specifying the path to the file and use the FileInfo object’s CopyTo method to create a copy of the file. Example code: FileInfo fi = new FileInfo(@"C:\file.txt");   if(fi.Exists) { fi.CopyTo(@"C:\copyfile.txt"); } Similar method can be used to move and […]
Continue reading…

Enjoyed this post? Share it!

 
 

How to get information about a file in c#

To obtain information about a file, we must create a new FileInfo object by specifying the path to the file and use the FileInfo object to retrieve information about the file. Example code: FileInfo fi = new FileInfo(@"C:\file.txt");   if(fi.Exists) { Console.WriteLine("Filename : {0}", fi.Name); Console.WriteLine("Path : {0}", fi.FullName); } The Exists property tells us […]
Continue reading…

Enjoyed this post? Share it!

 
 

Open a file in php for reading

The fopen($fileName, “r”) function allows developers to open a file and read its content. The function returns a file handle. The second argument “r” instructs PHP to open the file for reading. Once the file is open, other functions to read data from the file through the file handle can be used. Example code on […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read a file into a string using PHP

An entire file can be read into a single string using the file_get_contents() php function. The file function reads all the lines of a file and returns them in a single string. Example code on how to file_get_contents(): <?php $file = file_get_contents("/tmp/file.txt"); print("Size of the file: ".strlen($file)."\n"); ?> Output: Size of the file: 7362 The […]
Continue reading…

Enjoyed this post? Share it!

 
 

Read a file into an array using PHP

A file can be read into an array using the file() php function. The file function reads all the lines of a file and populates each line as a value in an array, and returns the array Example code on how to use file(): <?php $lines = file("/tmp/file.txt"); foreach ($lines as $line) { $line = […]
Continue reading…

Enjoyed this post? Share it!

 
 

File handling in PHP : Part 6 – Reading a file character by character

The fgetc() function is used to read a single character from a file at a time. After each call to this function, the file pointer will move to the next character. The following code is used to read a file character by character until the end of file is reached. 1 2 3 4 5 […]
Continue reading…

Enjoyed this post? Share it!