TECHNOLOGIES
FORUMS
JOBS
BOOKS
EVENTS
INTERVIEWS
Live
MORE
LEARN
Training
CAREER
MEMBERS
VIDEOS
NEWS
BLOGS
Sign Up
Login
No unread comment.
View All Comments
No unread message.
View All Messages
No unread notification.
View All Notifications
Answers
Post
An Article
A Blog
A News
A Video
An EBook
An Interview Question
Ask Question
Forums
Monthly Leaders
Forum guidelines
Nazar Mohammad
NA
9
1.4k
Conver the code of php in c#
May 7 2013 2:36 AM
class mytest extends Controller {
public function index(){
//CREATE A FILE
//generate random filename
$hash = strtoupper(md5(rand()));
$random_name = substr($hash, rand(0, 22),8);
//get random file from directory
$list = openDerictory("someplace/sdfs");
$randomFile = $list[array_rand($list)];
appendToFile("someplace/sdfs",$randomFile, $random_name);
///DO RANDOM THINGS
var $t = 'sdfs';
foreach($list as $item){
echo $t . $item;
}
//LET THE USER KNOW SOMETHING
echo "this is a test";
echo "we did somtyhing";
echo "try something else";
}
//Function to open Directory
function openDerictory($path, $type= ".txt")
{
$list = array();
if ($dh = opendir($path)) {
$count = 0;
while (($file = readdir($dh)) !== false) {
$info = pathinfo($path . $file);
if(strtolower($info['extension']) == strtolower($type)){
$list[$count] = $file;
$count++;
}
}
closedir($dh);
}
return $list;
}
function appendToFile($path ,$randomFile, $random_name)
{
//get contents
$file = file_get_contents($path . $randomFile, FILE_USE_INCLUDE_PATH);
//savefile
$fp = fopen($path . $random_name . 'ext','a');
fwrite($fp, $file);
fclose($fp);
}
}
Reply
Answers (
1
)
How to show expire message before 2 days in c# windows App
system boot at particular time