Click here to Skip to main content
Rate this: bad
good
Please Sign up or sign in to vote.
See more: C#
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 7:02am
Edited 28-Dec-12 7:25am
v2
Comments
Krunal Rohit at 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 at 26-Dec-12 12:16pm
   
?
farham_heidari at 26-Dec-12 12:09pm
   
?????????
Krunal Rohit at 26-Dec-12 12:20pm
   
Stream fs = FileUpload1.PostedFile.InputStream; comes after uploading the file..
Its my blind assumption....
farham_heidari at 26-Dec-12 12:27pm
   
i want to upload mystream that is a filestream but i have stream ...
Krunal Rohit at 26-Dec-12 12:31pm
   
you can use this : http://msdn.microsoft.com/en-us/library/dd783870.aspx
farham_heidari at 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 at 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 Smile | :)
  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
0 Maciej Los 372
1 ridoy 313
2 DamithSL 305
3 OriginalGriff 209
4 George Jonsson 140
0 OriginalGriff 7,968
1 DamithSL 6,179
2 Sergey Alexandrovich Kryukov 5,524
3 Maciej Los 5,438
4 Kornfeld Eliyahu Peter 4,539


Advertise | Privacy | Mobile
Web01 | 2.8.141223.1 | Last Updated 28 Dec 2012
Copyright © CodeProject, 1999-2014
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