tags:

views:

48

answers:

1

I want to convert the following PHP operation to C# code, could anyone please help me to convert this to C#.

$swfaddr = $absolutepath."/components/flash/".$slug.".swf";
$swf = fopen($swfaddr, "w");
fwrite($swf, file_get_contents($game['swf_url']));
$thumbaddr = $absolutepath."/components/images/".$slug.".gif";
$thumb = fopen($thumbaddr, "w");
fwrite($thumb, file_get_contents($game['thumbnail_url']));

Thanks

+1  A: 

Um google reading and writing files in c#. pick what works for you.

The strings would be replaced with something like this.

StringBuilder swfaddr = new StringBuilder();
swfaddr.Append(absolutePath);
swfaddr.Append("/components/flash/");
swfaddr.Append(slug);
swfaddr.Append(".swf");

The file operations would use a FileStream to either read / write.

So for example (psuedo code)

File.Open(swfaddr.ToString())
byte[] file.readbytes
File.Create(newfile, byte[])

So Google reading and writing files to find what works best for you. Most likely binary streams.

Joshua Cauble