Search
 
SCRIPT & CODE EXAMPLE
 

CSHARP

c# streamreader to file

// after .NET 4.0
using (var fileStream = File.Create("C:PathToFile"))
{
    myOtherObject.InputStream.Seek(0, SeekOrigin.Begin);
    myOtherObject.InputStream.CopyTo(fileStream);
}

// before .NET 4.0
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);
    }

	// streams are not closed
}
Comment

PREVIOUS NEXT
Code Example
Csharp :: c# multiple inheritance 
Csharp :: unity awake 
Csharp :: c# unit test exception using try catch 
Csharp :: letter to number converter c# 
Csharp :: how to use open hardware monitor in c# 
Csharp :: rows and columns arrays 
Csharp :: Non-Serialized Fields in unity inspector 
Csharp :: select a whole row out of a 2d array C# 
Csharp :: HtmlToPdfConverter 
Csharp :: c# list contains null 
Csharp :: c# switch expression pattern matching 
Csharp :: Severity Code Description Project File Line Suppression State Error MSB3021 
Csharp :: c# move directory 
Csharp :: c# external execute batch 
Csharp :: if or statement c# 
Csharp :: list cast< c# 
Csharp :: Using Linq to get the last N elements of a collection? C# 
Csharp :: c# textbox only numbers 
Csharp :: get list of months and year between two dates c# 
Csharp :: C# long 
Csharp :: orderby c# 
Csharp :: one line condition c# 
Csharp :: unity move camera to player fluent 
Csharp :: json serialize object capitalization config 
Csharp :: hive survive 
Csharp :: technische vragen c# 
Csharp :: c# fieldnullexception 
Csharp :: Get single listView SelectedItem 
Csharp :: wpf stackpanel horizontal 
Csharp :: drop column with code first asp.net core 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =