<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>C# 411 &#187; IO</title>
	<atom:link href="http://www.csharp411.com/category/io/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.csharp411.com</link>
	<description>C# Information, Code, Tips and News</description>
	<lastBuildDate>Mon, 19 Jul 2010 14:56:35 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.6</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Get Temporary Directory</title>
		<link>http://www.csharp411.com/get-temporary-directory/</link>
		<comments>http://www.csharp411.com/get-temporary-directory/#comments</comments>
		<pubDate>Sat, 01 May 2010 15:32:05 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/get-temporary-directory/</guid>
		<description><![CDATA[To get the path of the current user's temporary folder, call the GetTempPath method in the System.IO namespace:
string tempPath = System.IO.Path.GetTempPath();
  
On Windows Vista and 7, this method will return the following path:

C:\Users\UserName\AppData\Local\Temp\



Related posts:C# Copy Folder RecursivelyCheck Valid File Path in C#Truncate File Path with Ellipsis


Related posts:<ol><li><a href='http://www.csharp411.com/c-copy-folder-recursively/' rel='bookmark' title='Permanent Link: C# Copy Folder Recursively'>C# Copy Folder Recursively</a></li><li><a href='http://www.csharp411.com/check-valid-file-path-in-c/' rel='bookmark' title='Permanent Link: Check Valid File Path in C#'>Check Valid File Path in C#</a></li><li><a href='http://www.csharp411.com/truncate-file-path-with-ellipsis/' rel='bookmark' title='Permanent Link: Truncate File Path with Ellipsis'>Truncate File Path with Ellipsis</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/get-temporary-directory/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Read File into Byte Array</title>
		<link>http://www.csharp411.com/read-file-into-byte-array/</link>
		<comments>http://www.csharp411.com/read-file-into-byte-array/#comments</comments>
		<pubDate>Wed, 21 Apr 2010 20:13:37 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/read-file-into-byte-array/</guid>
		<description><![CDATA[It’s easy to read a file into a byte array.&#160; Just use the File.ReadAllBytes static method.&#160; This opens a binary file in read-only mode, reads the contents of the file into a byte array, and then closes the file.
string filePath = @&#34;C:\test.doc&#34;;
byte[] byteArray = File.ReadAllBytes( filePath );
  


Related posts:C# Read Text File Line-by-LineC# Convert [...]


Related posts:<ol><li><a href='http://www.csharp411.com/c-read-text-file-line-by-line/' rel='bookmark' title='Permanent Link: C# Read Text File Line-by-Line'>C# Read Text File Line-by-Line</a></li><li><a href='http://www.csharp411.com/c-convert-byte-array-to-string/' rel='bookmark' title='Permanent Link: C# Convert Byte Array to String'>C# Convert Byte Array to String</a></li><li><a href='http://www.csharp411.com/convert-string-to-byte-array/' rel='bookmark' title='Permanent Link: Convert String to Byte Array'>Convert String to Byte Array</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/read-file-into-byte-array/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Set InitialDirectory for FolderBrowserDialog</title>
		<link>http://www.csharp411.com/set-initialdirectory-for-folderbrowserdialog/</link>
		<comments>http://www.csharp411.com/set-initialdirectory-for-folderbrowserdialog/#comments</comments>
		<pubDate>Mon, 12 Apr 2010 20:34:40 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>
		<category><![CDATA[Windows Forms]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/set-initialdirectory-for-folderbrowserdialog/</guid>
		<description><![CDATA[The .NET FolderBrowserDialog class does not have an InitialDirectory property like the OpenFileDialog class.&#160; But fortunately, it’s quite easy to set an initial folder in the FolderBrowserDialog:
FolderBrowserDialog dialog = new FolderBrowserDialog();
dialog.RootFolder = Environment.SpecialFolder.Desktop;
dialog.SelectedPath = @&#34;C:\Program Files&#34;;
if (dialog.ShowDialog() == DialogResult.OK)
{
    Console.WriteLine( dialog.SelectedPath );
}

Note that you can choose other RootFolder’s like MyComputer and MyDocuments.&#160; [...]


Related posts:<ol><li><a href='http://www.csharp411.com/adding-assemblies-to-the-visual-studio-add-reference-dialog/' rel='bookmark' title='Permanent Link: Adding Assemblies to the Visual Studio &#34;Add Reference&#34; Dialog'>Adding Assemblies to the Visual Studio &#34;Add Reference&#34; Dialog</a></li><li><a href='http://www.csharp411.com/console-output-from-winforms-application/' rel='bookmark' title='Permanent Link: Console Output from a WinForms Application'>Console Output from a WinForms Application</a></li><li><a href='http://www.csharp411.com/the-proper-way-to-show-the-wait-cursor/' rel='bookmark' title='Permanent Link: The Proper Way to Show the Wait Cursor'>The Proper Way to Show the Wait Cursor</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/set-initialdirectory-for-folderbrowserdialog/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>C# Read String Line by Line</title>
		<link>http://www.csharp411.com/c-read-string-line-by-line/</link>
		<comments>http://www.csharp411.com/c-read-string-line-by-line/#comments</comments>
		<pubDate>Fri, 20 Feb 2009 14:48:54 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-read-string-line-by-line/</guid>
		<description><![CDATA[It’s easy to read a string one line at a time.&#160; Here is a console program that demonstrates how:
  
using System;
using System.IO; 

namespace CSharp411
{
    class Program
    {
        static void Main( string[] args )
        {
 [...]


Related posts:<ol><li><a href='http://www.csharp411.com/c-read-text-file-line-by-line/' rel='bookmark' title='Permanent Link: C# Read Text File Line-by-Line'>C# Read Text File Line-by-Line</a></li><li><a href='http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/' rel='bookmark' title='Permanent Link: C# Convert String to Stream, and Stream to String'>C# Convert String to Stream, and Stream to String</a></li><li><a href='http://www.csharp411.com/c-read-text-file-into-string/' rel='bookmark' title='Permanent Link: C# Read Text File into String'>C# Read Text File into String</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-read-string-line-by-line/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Convert String to Stream, and Stream to String</title>
		<link>http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/</link>
		<comments>http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/#comments</comments>
		<pubDate>Thu, 19 Feb 2009 22:20:43 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/</guid>
		<description><![CDATA[It’s fairly easy to convert a C# String to a Stream and vice-versa.

Convert String to Stream
To convert a C# String to a MemoryStream object, use the GetBytes Encoding method to create a byte array, then pass that to the MemoryStream constructor:
byte[] byteArray = Encoding.ASCII.GetBytes( test );
MemoryStream stream = new MemoryStream( byteArray ); 
Convert Stream to [...]


Related posts:<ol><li><a href='http://www.csharp411.com/convert-string-to-byte-array/' rel='bookmark' title='Permanent Link: Convert String to Byte Array'>Convert String to Byte Array</a></li><li><a href='http://www.csharp411.com/c-convert-byte-array-to-string/' rel='bookmark' title='Permanent Link: C# Convert Byte Array to String'>C# Convert Byte Array to String</a></li><li><a href='http://www.csharp411.com/convert-binary-to-base64-string/' rel='bookmark' title='Permanent Link: Convert Binary to Base64 String'>Convert Binary to Base64 String</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-convert-string-to-stream-and-stream-to-string/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>C# Read Text File Line-by-Line</title>
		<link>http://www.csharp411.com/c-read-text-file-line-by-line/</link>
		<comments>http://www.csharp411.com/c-read-text-file-line-by-line/#comments</comments>
		<pubDate>Thu, 15 Jan 2009 15:29:48 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-read-text-file-line-by-line/</guid>
		<description><![CDATA[Here is the code to read a text file from disk one line at a time into a string.  This code ensures the file exists and properly closes the file if an exception occurs.

using System;
using System.IO; 

namespace CSharp411
{
    class Program
    {
        static [...]


Related posts:<ol><li><a href='http://www.csharp411.com/c-read-string-line-by-line/' rel='bookmark' title='Permanent Link: C# Read String Line by Line'>C# Read String Line by Line</a></li><li><a href='http://www.csharp411.com/c-read-text-file-into-string/' rel='bookmark' title='Permanent Link: C# Read Text File into String'>C# Read Text File into String</a></li><li><a href='http://www.csharp411.com/read-file-into-byte-array/' rel='bookmark' title='Permanent Link: Read File into Byte Array'>Read File into Byte Array</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-read-text-file-line-by-line/feed/</wfw:commentRss>
		<slash:comments>13</slash:comments>
		</item>
		<item>
		<title>Check Valid File Path in C#</title>
		<link>http://www.csharp411.com/check-valid-file-path-in-c/</link>
		<comments>http://www.csharp411.com/check-valid-file-path-in-c/#comments</comments>
		<pubDate>Thu, 17 Jul 2008 12:45:06 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/check-valid-file-path-in-c/</guid>
		<description><![CDATA[It's not a trivial exercise to validate a file path on a Windows PC.  There are a few special cases depending on the file system and operating subsystem:

NTFS and the Posix file systems are the most permissive.  A file name may contain up to 32,768 Unicode characters, trailing periods, trailing spaces, and two files may [...]


Related posts:<ol><li><a href='http://www.csharp411.com/truncate-file-path-with-ellipsis/' rel='bookmark' title='Permanent Link: Truncate File Path with Ellipsis'>Truncate File Path with Ellipsis</a></li><li><a href='http://www.csharp411.com/searchreplace-in-files/' rel='bookmark' title='Permanent Link: C# Search/Replace in Files'>C# Search/Replace in Files</a></li><li><a href='http://www.csharp411.com/c-copy-folder-recursively/' rel='bookmark' title='Permanent Link: C# Copy Folder Recursively'>C# Copy Folder Recursively</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/check-valid-file-path-in-c/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Display an RTF File that&#039;s a C# Embedded Resource</title>
		<link>http://www.csharp411.com/display-an-rtf-file-thats-a-c-embedded-resource/</link>
		<comments>http://www.csharp411.com/display-an-rtf-file-thats-a-c-embedded-resource/#comments</comments>
		<pubDate>Wed, 16 Jul 2008 13:59:27 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[Controls]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/display-an-rtf-file-thats-a-c-embedded-resource/</guid>
		<description><![CDATA[It's easy to display an RTF file &#8212; that was embedded as a resource in a C# program &#8212; in a Windows Form RichTextControl.

First, include the following references:
using System.IO;
using System.Reflection;

Next, load the RTF that you have embedded in your Visual Studio project:
Assembly asm = Assembly.GetExecutingAssembly();
Stream stream = asm.GetManifestResourceStream( &#34;MyNamespace.FileName.rtf&#34; );

RichTextBox rt = new RichTextBox();
rt.LoadFile( stream, [...]


Related posts:<ol><li><a href='http://www.csharp411.com/embedded-image-resources/' rel='bookmark' title='Permanent Link: Embedded Image Resources'>Embedded Image Resources</a></li><li><a href='http://www.csharp411.com/check-valid-file-path-in-c/' rel='bookmark' title='Permanent Link: Check Valid File Path in C#'>Check Valid File Path in C#</a></li><li><a href='http://www.csharp411.com/truncate-file-path-with-ellipsis/' rel='bookmark' title='Permanent Link: Truncate File Path with Ellipsis'>Truncate File Path with Ellipsis</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/display-an-rtf-file-thats-a-c-embedded-resource/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>C# Copy Folder Recursively</title>
		<link>http://www.csharp411.com/c-copy-folder-recursively/</link>
		<comments>http://www.csharp411.com/c-copy-folder-recursively/#comments</comments>
		<pubDate>Wed, 09 Jul 2008 15:19:40 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-copy-folder-recursively/</guid>
		<description><![CDATA[Sadly there is no built-in function in System.IO that will copy a folder and its contents.&#160; Following is a simple recursive algorithm that copies a folder, its sub-folders and files, creating the destination folder if needed.&#160; For simplicity, there is no error handling; an exception will throw if anything goes wrong, such as null or [...]


Related posts:<ol><li><a href='http://www.csharp411.com/check-valid-file-path-in-c/' rel='bookmark' title='Permanent Link: Check Valid File Path in C#'>Check Valid File Path in C#</a></li><li><a href='http://www.csharp411.com/get-temporary-directory/' rel='bookmark' title='Permanent Link: Get Temporary Directory'>Get Temporary Directory</a></li><li><a href='http://www.csharp411.com/c-read-text-file-line-by-line/' rel='bookmark' title='Permanent Link: C# Read Text File Line-by-Line'>C# Read Text File Line-by-Line</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-copy-folder-recursively/feed/</wfw:commentRss>
		<slash:comments>29</slash:comments>
		</item>
		<item>
		<title>C# Read Text File into String</title>
		<link>http://www.csharp411.com/c-read-text-file-into-string/</link>
		<comments>http://www.csharp411.com/c-read-text-file-into-string/#comments</comments>
		<pubDate>Tue, 01 Jul 2008 16:09:24 +0000</pubDate>
		<dc:creator>timm</dc:creator>
				<category><![CDATA[C#]]></category>
		<category><![CDATA[IO]]></category>
		<category><![CDATA[Tips]]></category>

		<guid isPermaLink="false">http://www.csharp411.com/c-read-text-file-into-string/</guid>
		<description><![CDATA[Here is the easiest way to read an entire text file into a C# string:
string s = System.IO.File.ReadAllText( path );
  


Related posts:C# Read Text File Line-by-LineRead File into Byte ArrayCheck Valid File Path in C#


Related posts:<ol><li><a href='http://www.csharp411.com/c-read-text-file-line-by-line/' rel='bookmark' title='Permanent Link: C# Read Text File Line-by-Line'>C# Read Text File Line-by-Line</a></li><li><a href='http://www.csharp411.com/read-file-into-byte-array/' rel='bookmark' title='Permanent Link: Read File into Byte Array'>Read File into Byte Array</a></li><li><a href='http://www.csharp411.com/check-valid-file-path-in-c/' rel='bookmark' title='Permanent Link: Check Valid File Path in C#'>Check Valid File Path in C#</a></li></ol>]]></description>
		<wfw:commentRss>http://www.csharp411.com/c-read-text-file-into-string/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
	</channel>
</rss>
