Click here to Skip to main content
13,044,467 members (120,350 online)
Rate this:
 
Please Sign up or sign in to vote.
See more:
Hi.

I have file uploader and I want to upload a file with FTP and FTPUpload class. I need the filestream how can I get filestream from file uploader ??

How can I copy stream to file Stream ?

 System.IO.FileStream myStream;
 Stream fs = FileUpload1.PostedFile.InputStream;
// Code here to write in mySteam From Stram fs
 Upload.FTPUpload(myStream, "*********", "******", "*******");
Posted 26-Dec-12 6:02am
Updated 28-Dec-12 6:25am
v2
Comments
Krunal Rohit 26-Dec-12 12:08pm
   
System.IO.FileStream myStream;

// Code here to write in mySteam From Stram fs
Upload.FTPUpload(myStream, "*********", "******", "*******");
Stream fs = FileUpload1.PostedFile.InputStream;
farham_heidari 26-Dec-12 12:16pm
   
?
farham_heidari 26-Dec-12 12:09pm
   
?????????
Krunal Rohit 26-Dec-12 12:20pm
   
Stream fs = FileUpload1.PostedFile.InputStream; comes after uploading the file..
Its my blind assumption....
farham_heidari 26-Dec-12 12:27pm
   
i want to upload mystream that is a filestream but i have stream ...
Krunal Rohit 26-Dec-12 12:31pm
   
you can use this : http://msdn.microsoft.com/en-us/library/dd783870.aspx
farham_heidari 26-Dec-12 12:41pm
   
i can't find anything useful there . . . i just want read a file from fileuploder and upload it with ftpupload class
Suvabrata Roy 27-Dec-12 5:13am
   
public static void CopyStream(Stream input, Stream output)
{
byte[] buffer = new byte[8 * 1024];
int len;
while ( (len = input.Read(buffer, 0, buffer.Length)) > 0)
{
output.Write(buffer, 0, len);
}
}
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

Hi,

Kunal he is trying to Convert stream to file stream,

public static void CopyStream(Stream input, Stream output)
{
    byte[] buffer = new byte[8 * 1024];
    int len;
    while ( (len = input.Read(buffer, 0, buffer.Length)) > 0)
    {
        output.Write(buffer, 0, len);
    }
}


This will help you :)
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

it's not change stream to file stream it's just copy a input stream to output stream
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.170713.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100