Click here to Skip to main content
16,008,954 members
Home / Discussions / Web Development
   

Web Development

 
AnswerRe: What error is this?(Javascript) Pin
Alsvha28-Sep-05 22:35
Alsvha28-Sep-05 22:35 
GeneralRe: What error is this?(Javascript) Pin
AlphonseElric28-Sep-05 22:52
AlphonseElric28-Sep-05 22:52 
AnswerRe: What error is this?(Javascript) Pin
Guffa28-Sep-05 23:02
Guffa28-Sep-05 23:02 
GeneralRe: What error is this?(Javascript) Pin
AlphonseElric28-Sep-05 23:16
AlphonseElric28-Sep-05 23:16 
GeneralRe: What error is this?(Javascript) Pin
Guffa29-Sep-05 12:19
Guffa29-Sep-05 12:19 
GeneralRe: What error is this?(Javascript) Pin
AlphonseElric29-Sep-05 14:52
AlphonseElric29-Sep-05 14:52 
GeneralRe: What error is this?(Javascript) Pin
Guffa29-Sep-05 22:07
Guffa29-Sep-05 22:07 
Questionsimply saving a remote binary file (swf) locally Pin
sascho28-Sep-05 11:26
sascho28-Sep-05 11:26 
Hi there!

I am trying to save different .swf files on my local machine.
Actually this is already working with the below code.
Unfortunately (how I already figured while writing the code) The file is saved, but somehow corrupted.

Is there maybe a way more simple way to get the Response of an URI into a string (or, let's say a buffer) and save it on my disk?


Below is the code I came up with (within a C# web application):

// init
bool debug = false;
// this is where I get my test-swf, you can have a look at it at:
// http://www.styte.com/3.swf
// it may look strange, what I am trying to do is to read some php-created
// swf's into my .net application....
string url = "http://www.styte.com/trans.php?&bild=3.swf";

// work
Uri fileUrl = new Uri(url);
// Create 'FileWebrequest' object with specified Uri.
WebRequest myFileWebRequest = (WebRequest)WebRequest.Create(fileUrl);
// Send 'FileWebRequest' object & wait for response.
WebResponse myFileWebResponse = (WebResponse)myFileWebRequest.GetResponse();

// Get stream object associated with response object.
Stream receiveStream = myFileWebResponse.GetResponseStream();

Encoding encode = System.Text.Encoding.GetEncoding("windows-1252"); //("utf-8");
// Pipe stream to higher level stream reader with req. encoding format.
StreamReader readStream = new StreamReader (receiveStream, encode);
if (debug==true) Response.Write("\r\nResponse stream received<br>");

int numChars = 1;
Char[] read = new Char[numChars];
// Read "numChars" characters at a time.

int count = readStream.Read ( read, 0, numChars );
if (debug==true) Response.Write("(count): "+count.ToString()+" File Data...\r\n");
//Response.ContentType = "application/x-shockwave-flash";
//Response.AddHeader("Content-Type", "application/x-shockwave-flash");
FileStream fs = File.Create(@"C:\Inetpub\wwwroot\leilac\uploads\test.swf");
BinaryWriter bw = new BinaryWriter(fs);
while (count > 0) {
String str = new String(read, 0, count);
bw.Write(str);
Response.Write(str);
count = readStream.Read(read, 0, numChars);
}
bw.Close(); fs.Close();
if (debug==true) Response.Write("<br>");
// Release resources of stream & response object.
readStream.Close();
myFileWebResponse.Close();
Response.End();



Appreciate any comments/help.

Sascha Stanscheit, styte, http://www.styte.com/
AnswerRe: simply saving a remote binary file (swf) locally Pin
Guffa28-Sep-05 12:30
Guffa28-Sep-05 12:30 
QuestionReplace a substring Pin
sabustep28-Sep-05 4:46
susssabustep28-Sep-05 4:46 
AnswerRe: Replace a substring Pin
Guffa28-Sep-05 5:30
Guffa28-Sep-05 5:30 
AnswerRe: Replace a substring Pin
Brian Van Beek28-Sep-05 11:17
Brian Van Beek28-Sep-05 11:17 
QuestionI need javascript function which take two parameters(dates) and return total years and months difference Pin
TariqMahmood28-Sep-05 2:18
TariqMahmood28-Sep-05 2:18 
AnswerRe: I need javascript function which take two parameters(dates) and return total years and months difference Pin
Guffa28-Sep-05 2:27
Guffa28-Sep-05 2:27 
QuestionTo disable the back button on the ie Pin
anishyanic28-Sep-05 1:37
anishyanic28-Sep-05 1:37 
AnswerRe: To disable the back button on the ie Pin
Brian Van Beek28-Sep-05 11:23
Brian Van Beek28-Sep-05 11:23 
AnswerRe: To disable the back button on the ie Pin
minhpc_bk28-Sep-05 16:09
minhpc_bk28-Sep-05 16:09 
Questionconvert php to asp.net Pin
ali bagheri28-Sep-05 1:27
ali bagheri28-Sep-05 1:27 
AnswerRe: convert php to asp.net Pin
ali bagheri28-Sep-05 2:09
ali bagheri28-Sep-05 2:09 
Questionchanging culture Pin
wpcolleen27-Sep-05 23:49
wpcolleen27-Sep-05 23:49 
AnswerRe: changing culture Pin
minhpc_bk28-Sep-05 16:05
minhpc_bk28-Sep-05 16:05 
GeneralRe: changing culture Pin
wpcolleen28-Sep-05 21:28
wpcolleen28-Sep-05 21:28 
GeneralRe: changing culture Pin
minhpc_bk29-Sep-05 0:27
minhpc_bk29-Sep-05 0:27 
QuestionConnect to an Access file outside my local network Pin
kokain27-Sep-05 23:28
kokain27-Sep-05 23:28 
AnswerRe: Connect to an Access file outside my local network Pin
enjoycrack27-Sep-05 23:49
enjoycrack27-Sep-05 23:49 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Praise Praise    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.