Solved

PHP to C#

Posted on 2013-01-26
7
270 Views
Last Modified: 2013-02-04
Hi,

How can I convert the attahed PHP code to C#?

ayha
stlvolume.php
0
Comment
Question by:ayha1999
  • 3
  • 3
7 Comments
 
LVL 55

Accepted Solution

by:
Jaime Olivares earned 250 total points
Comment Utility
First of all, remove all the $ !!!

The code snippet basically reads a binary file, so you will need to use BinaryReader. So, instead of the following

$fp = fopen($filepath, "rb");
$section = file_get_contents($filepath, NULL, NULL, 0, 79);
fseek($fp, 80);
$data = fread($fp, 4);
$numOfFacets = unpack("I", $data);
for ($i = 0; $i < $numOfFacets[1]; $i++){
	//Start Normal Vector
	$data = fread($fp, 4);
	$hold = unpack("f", $data);

Open in new window

you do:

using (BinaryReader fp = new BinaryReader(File.Open(filepath, FileMode.Open)))
{
    fp.BaseStream.Position = 80;
    var numOfFacets = fp.ReadInt32();
    for (int i = 0; i< numOfFacets; i++) {
         var hold = fp.ReadSingle();
// etcetera

Open in new window

0
 
LVL 7

Author Comment

by:ayha1999
Comment Utility
could u please convert the complete code?

Thanks
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
Hello ayha1999,
This is not a do-my-job-for-me site, but a collaboration site where volunteers try to solve your questions.
I already answered your question: "How can I convert the attahed PHP code to C#?"

From now on, you should try to do it by yourself and come back with any other question in order to acomplish your task.
0
Enabling OSINT in Activity Based Intelligence

Activity based intelligence (ABI) requires access to all available sources of data. Recorded Future allows analysts to observe structured data on the open, deep, and dark web.

 
LVL 7

Author Comment

by:ayha1999
Comment Utility
Is there by php to c# conversion utility or php to asp.net project migration tool?

Thanks
0
 
LVL 55

Expert Comment

by:Jaime Olivares
Comment Utility
There is not such thing, as far as I know.
The problem is that you don't want to convert the language itself but the framework library. Even worst, the standard PHP library is not object oriented but just a collection of functions, while the .net framework library is fully OO.
So, there is not other solution than translating it manually, which is quiet easy for something that knows about it.
0
 

Assisted Solution

by:kottamgari
kottamgari earned 250 total points
Comment Utility
0
 
LVL 7

Author Closing Comment

by:ayha1999
Comment Utility
Thanks
0

Featured Post

Free Trending Threat Insights Every Day

Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

Join & Write a Comment

Suggested Solutions

Author Note: Since this E-E article was originally written, years ago, formal testing has come into common use in the world of PHP.  PHPUnit (http://en.wikipedia.org/wiki/PHPUnit) and similar technologies have enjoyed wide adoption, making it possib…
Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
Learn how to match and substitute tagged data using PHP regular expressions. Demonstrated on Windows 7, but also applies to other operating systems. Demonstrated technique applies to PHP (all versions) and Firefox, but very similar techniques will w…
The viewer will learn how to create and use a small PHP class to apply a watermark to an image. This video shows the viewer the setup for the PHP watermark as well as important coding language. Continue to Part 2 to learn the core code used in creat…

772 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

12 Experts available now in Live!

Get 1:1 Help Now